UnityNativeGallery icon indicating copy to clipboard operation
UnityNativeGallery copied to clipboard

Ios16 : Can't get saved image

Open CandyAlla opened this issue 3 years ago • 6 comments

system : ios16 step1 : Save image to photo album use path : Application.persistentDataPath .. "/NGallery/XXX.jpg" step2 : Get image from Application.persistentDataPath .. "/NGallery/XXX.jpg", but report an error with "Load fail" step3 : Check the photo album , I see the photo just saved.

CandyAlla avatar Oct 08 '22 13:10 CandyAlla

Also , I load the image with other plugin's function is failed too

CandyAlla avatar Oct 08 '22 13:10 CandyAlla

Are you deleting the image from persistentDataPath after saving it? If not, why does load fail? Are there specific error messages? Note that the image is copied to photo album so the image at persistentDataPath isn't the same image file that exists in Photos.

yasirkula avatar Oct 08 '22 16:10 yasirkula

I didn't delete the image. I lost the erro log. You can have a try. First: NativeGallery.SaveImageToGallery;
Second: path = Application.persistentDataPath .. "/NGallery/XX_share.jpg" local img = NativeGallery.LoadImageAtPath(path, -1, true, true, false) if img then logRed("load image :" .. img.name) end

CandyAlla avatar Oct 09 '22 02:10 CandyAlla

I don't have an iOS or Mac workstation so I can't give it a try myself. Please let me know if you find any related error messages that might help. Also seeing the code itself might help.

yasirkula avatar Oct 09 '22 07:10 yasirkula

I don't have an iOS or Mac workstation so I can't give it a try myself. Please let me know if you find any related error messages that might help. Also seeing the code itself might help.

I meet similar problem. After i called the SaveVideoToGallery, the callback returned success but the path is empty. Btw, on android in the callback the path returned correct path string.

NativeGallery.Permission permission = NativeGallery.SaveVideoToGallery( outputVideoPath, "GalleryTest", videoName, ( success, path ) => { Debug.Log( "Media save result: " + success + " " + path ); Debug.Log( "Video path: " + path ); //Handheld.PlayFullScreenMovie( "file://" + path ); } );

Media save result: True UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object) UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[]) UnityEngine.Logger:Log(LogType, Object) UnityEngine.Debug:Log(Object) <>c:<SaveVideoToAlbumCoroutine>b__64_0(Boolean, String) NativeGallery:SaveToGalleryInternal(String, String, MediaType, MediaSaveCallback) NativeGalleryNamespace.NGMediaSaveCallbackiOS:OnMediaSaveCompleted(String)

Video path: UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object) UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[]) UnityEngine.Logger:Log(LogType, Object) UnityEngine.Debug:Log(Object) <>c:<SaveVideoToAlbumCoroutine>b__64_0(Boolean, String) NativeGallery:SaveToGalleryInternal(String, String, MediaType, MediaSaveCallback) NativeGalleryNamespace.NGMediaSaveCallbackiOS:OnMediaSaveCompleted(String)

ojama avatar Jul 26 '24 03:07 ojama

@ojama That's expected as per documentation:

MediaSaveCallback takes bool success and string path parameters. If the image/video is saved successfully, success becomes true. On Android, path stores where the image/video was saved to (is null on iOS). If the raw filepath can't be determined, an abstract Storage Access Framework path will be returned (File.Exists returns false for that path)

yasirkula avatar Jul 26 '24 13:07 yasirkula