0

relatively newbie question about meteor mobile (Android). I'm a bit lost regarding the inclusion of images and other assets into the Cordova build of my Meteor app (just so the Android app doesn't have to download the images off the server, and just include it in the build.)

I've tried pasting the same images I added in the public folder inside Cordova build folder (inside the project) but I don't think that's how it works. And another is how to use those images as a source for the img items.

The end goal is to be able to direct the img src to a local file included in the build so that it doesn't have to download it from the server.

I hope to hear some advice soon! Thank you!

remingtonchan
  • 479
  • 4
  • 11
  • If you have just a few images you could embed them as base64 string inside an if is Cordova condition. – Jankapunkt Sep 24 '18 at 06:36
  • Which rendering system do you use? (Blaze, React, Angular, Vue...) – Jankapunkt Sep 24 '18 at 08:05
  • @Jankapunkt I use React. I'm not sure what you mean by Cordova condition, but I plan to show the images through the standard img tag with a src property. (It's the only way I'm currently familiar with.) I feel like I've taken steps closer to the answer. Using cordova-plugin-file, and gaining access to /android_assets/ but I don't know where that is in my project structure. – remingtonchan Sep 24 '18 at 15:52
  • There is a flag to check, whether Meteor is running on a Cordova environment: https://docs.meteor.com/api/core.html#Meteor-isCordova – Jankapunkt Sep 24 '18 at 16:05
  • @Jankapunkt Yeah, I got that down. I made a mistake in my testing, and apparently, linking to the public folder in the project structure will still work properly (and locally) in an Android build. While it's not safe-safe, I suppose this will do for my current objective. Thank you for the comments! – remingtonchan Sep 24 '18 at 16:49

1 Answers1

1

As per our discussion here: https://forums.meteor.com/t/how-to-use-webapplocalserver-localfilesystemurl-documentation-or-example/29881/2

The solution is to use a relative URL /myImage.jpg. When served via cordova this will point to the applications local storage of static resources.

Zack Newsham
  • 2,810
  • 1
  • 23
  • 43