BigImageViewer
BigImageViewer copied to clipboard
android 10 保存图片失败,android 10会将图片mime type识别成/octet-stream,导致保存失败
android 10 保存图片失败,android 10会将图片mime type识别成/octet-stream,导致保存失败

图片测试地址:https://cdn.cfesport.com//attachment/2019/11/07eba2e80aae.com/large/pgc-image/3f23c2de986540609e9846f233c3ee23?imageView2/0/h/700/q/80
PR is welcome!
This issue has been fixed in the latest version(v1.6.5), but not completely: contentValues.put(MediaStore.MediaColumns.DISPLAY_NAME, mCurrentImageFile.getName()); glide-cached file's name doesn't have "jpg" extension, This will cause the saved file not to be found in the system album. Suggest to check file extension before save. @Piasy
I verified that it worked fine on Pixel, which device are you using?
My device is HUAWEI P20 pro (Android 10), the saved file (without .jpg extension) can be found in file system, but not invisible in system Gallery, also can't be imported in app (e.g. WeChat). if the file is appended the ".jpg", everything is solved
How about save an image in png or gif format? @moodcal
I have tested a gif file on my device(P20Pro), not working correctly(the saved file is treated as jpeg, no animation, but can be animated when imported in WeChat), so the format detection should be done before appending the extension.
Yeah, that's true. It worked on Google Photos when I tested on Pixel, so I didn't add that logic. Looks like necessary now.
My idea is parsing file header, but not sure if common formats have such header.
BTW, PR is welcome!
A simple solution is to use the mUri's extension directly :-)
That's very easy to break, many social media don't have extension in their image url.
Yeah, but it's understandable to keep the same extension as the original file
java.lang.IllegalArgumentException: MIME type application/octet-stream cannot be inserted into content://media/external/images/media; expected MIME type under image/* at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:170) at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:140) at android.content.ContentProviderProxy.insert(ContentProviderNative.java:481) at android.content.ContentResolver.insert(ContentResolver.java:1828) at android.provider.MediaStore.createPending(MediaStore.java:616) at android.provider.MediaStore$Images$Media.insertImage(MediaStore.java:1736) at com.github.piasy.biv.view.BigImageView.saveImageIntoGallery(:2)