I’ve searched for this for quite some time and I haven’t been able to find a solution.
Here is the scenario: I have multiple avatar images that I want a user to be able to select from. Once they select their avatar image, I need to send it, as a binary file, to an API.
The problem: The path to the avatar is just relative ( assets/img/avatar-1.jpg ). So, when I attempt to upload it to an API ( using the Transfer module from ionic-native ), I get an error saying “no such file or directory exists” because it’s trying to upload the image thinking that assets/img/avatar-1.jpg is the absolute path.
So, what I think I need to do, is utilize the File module ( also from ionic-native ) and its cordova.file.* paths. The problem is that I don’t have any idea which of these cordova.file.* paths the src/assets/img directory would be found in. Furthermore, I don’t really know how I would go about searching them. Another problem is that I need to be able to find these absolute paths in iOS and Android. And they may have different cordova.file.* paths to get to the src/assets directory.
Has anyone run into a similar situation where they need to get the absolute path of a file in the assets directory of an Ionic project?
Or is there a better solution? All I really want to do is be able to send a file from my project’s assets directory to an API as a binary file.