Closed syahnur197 closed 4 years ago
I also have the same problem. Any solution on this?
i'm also getting same issue
Same issue here, on {NS} 6.4 with Vue.
Same issue here. NS 6.4 using Vue
Yes I am seeing the same on iOS with NS 6.2 with Angular
Camera roll images are affected by cloud services. On phones with cloud enabled local copies may be evicted leaving just a thumbnail behind. The actual data can be copied in the cloud and downloaded later if requested. This applies for both Android and iOS.
The image-picker selection returns ImageAsset objects. These objects are abstraction over PHAsset for iOS and similar URI based mechanisms for Android.
The core-modules have ImageSource class that handles image data that is available on the phone and can be rendered in UI, saved to file etc. See https://docs.nativescript.org/api-reference/modules/_image_source_#fromasset how you can obtain ImageSource for each ImageAsset. When you convert ImageAsset to ImageSource the actual image data may be downloaded from the cloud behind the scenes.
After obtaining ImageSource save the actual image to a temp folder using ImageSource saveToFile: https://docs.nativescript.org/api-reference/classes/_image_source_.imagesource#savetofile see the known folders "temp" field: https://docs.nativescript.org/api-reference/modules/_file_system_.knownfolders#temp
After saving the images to a temporary location you can use them in the background-http. It is important to copy them in temp file as the original images local files can be deleted to free up space before the background upload completes to free up space.
@pana-cc I will try to do as advised, thank you! One more question though, on Android I am sending the image file to the API server, upon receiving the content-length header shows the image's size correctly but the file saved has 0 length. I read somewhere that this may happen on the code running in emulator (and not on a real device) is that true?
It works! Thank you very much!
Camera roll images are affected by cloud services. On phones with cloud enabled local copies may be evicted leaving just a thumbnail behind. The actual data can be copied in the cloud and downloaded later if requested. This applies for both Android and iOS.
The image-picker selection returns ImageAsset objects. These objects are abstraction over PHAsset for iOS and similar URI based mechanisms for Android.
The core-modules have ImageSource class that handles image data that is available on the phone and can be rendered in UI, saved to file etc. See https://docs.nativescript.org/api-reference/modules/_image_source_#fromasset how you can obtain ImageSource for each ImageAsset. When you convert ImageAsset to ImageSource the actual image data may be downloaded from the cloud behind the scenes.
After obtaining ImageSource save the actual image to a temp folder using ImageSource saveToFile: https://docs.nativescript.org/api-reference/classes/_image_source_.imagesource#savetofile see the known folders "temp" field: https://docs.nativescript.org/api-reference/modules/_file_system_.knownfolders#temp
After saving the images to a temporary location you can use them in the background-http. It is important to copy them in temp file as the original images local files can be deleted to free up space before the background upload completes to free up space.
Hi @pana-cc, thank you for describing in details how it works for images stored in the cloud. Is there a similar technique for the videos? I've been working on video uploads for four weeks now and we're starting to think NS was not the best choice because we've had issues with AWS plugins first (most of them are deprecated or not well documented) and we're having a problem uploading videos from the device. I tried using ImageSource.fromAsset but it works only for images (png
, jpeg
, jpg
).
Any help would be highly appreciated at this point.
Thank you, Andrew
I want to upload the image selected to my server, this is not a problem for Android. If I console.log(selections[0])
{ "_observers":{}, "_options":{ "keepAspectRatio":true, "autoScaleFactor":true}, "_android":"image_path_here.jpg" } }
if ios I get this instead
{ "_observers":{}, "_options":{ "keepAspectRatio":true, "autoScaleFactor":true}, "_ios": {} } }
So I get empty if I do this selections[0].src.ios, but I will get something if I do this selections[0].src.android