react-native-image-resizer
react-native-image-resizer copied to clipboard
outputPath does not work correctly on iOS
When specifying the outputPath, Android works correctly and the output file is placed in the following folder for example (exactly what was provided to the library).
data/user/0/net.eksperience.myapp/cache/MB_ImageCompressor/c4e80d26-8055-4c1b-84ed-d47ab9b2aa3a.WEBP
However, on iOS, when I provide an outputPath of
/var/mobile/Containers/Data/Application/C5B63F2E-6A2C-4A1F-8745-8F23445FDE50/Library/Caches/MB_ImageCompressor
the file is not stored in the correct location. It seems like the provided outputPath just gets appended to whenever it was going to store the file. The result is this
'/var/mobile/Containers/Data/Application/C5B63F2E-6A2C-4A1F-8745-8F23445FDE50/Documents/var/mobile/Containers/Data/Application/C5B63F2E-6A2C-4A1F-8745-8F23445FDE50/Library/Caches/MB_ImageCompressor/0BAABF92-984C-48A6-BC72-2594851E07D6.jpg'
I also tried to just provide the folder name, and that does not work either because instead of storing it in Caches/folderName, it stores it in Documents.
Any idea what might be going wrong here ?
Hi @Saikedo,
On which version are you experiencing the issue ? Can you provide me an example ?
If you want to investigation deeper on your side I think you should look into ios/ImageResizer.mm in generateFilePathmethod.
Hi @taboulot
I just actually realized that this is the one that I was using and it seems like that one is deprecated https://www.npmjs.com/package/react-native-image-resizer. It was using 1.4.5.
Will try with the new one and will keep you posted if the same issue is occurring there as well.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I am having this issue and I am using 3.0.4. Were you able to figure this out?
Has anyone fixed this out? We are unfortunately abandoning the library if we can't fix this.
@Saikedo & @codeundercoverdev
Finally, I had time to look deeper.
The related code is here : https://github.com/bamlab/react-native-image-resizer/blob/254e4df2aa2889d223af84006d3a06ce9864a8f1/ios/ImageResizer.mm#L133-L139
The problem (it looks like it was already the case before) is that :
- The image is saved inside the
Cachedirectory if nooutputPathhas been provided; - If
outputPathis a subdirectory ofDocuments, it is created there ; - Else, the provided
outputPathis added toDocumentspath (it explains what you have @Saikedo );
Two solutions here :
- Do not save in
Cachedirectory, useDocumentsinstead; - Contributions are welcome to improve this part :)
I hope it helped.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically closed. Thank you for your contributions.