Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

android 10 保存图片失败,android 10会将图片mime type识别成/octet-stream,导致保存失败 #183

Open
crzaycat opened this issue Nov 8, 2019 · 11 comments
Labels

Comments

@crzaycat
Copy link

crzaycat commented Nov 8, 2019

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

图片测试地址:https://cdn.cfesport.com//attachment/2019/11/07eba2e80aae.com/large/pgc-image/3f23c2de986540609e9846f233c3ee23?imageView2/0/h/700/q/80

@Piasy
Copy link
Owner

Piasy commented Nov 8, 2019

PR is welcome!

@Piasy Piasy added the bug label May 15, 2020
@moodcal
Copy link

moodcal commented May 15, 2020

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

@Piasy
Copy link
Owner

Piasy commented May 15, 2020

I verified that it worked fine on Pixel, which device are you using?

@moodcal
Copy link

moodcal commented May 16, 2020

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

@Piasy
Copy link
Owner

Piasy commented May 16, 2020

How about save an image in png or gif format? @moodcal

@moodcal
Copy link

moodcal commented May 17, 2020

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.

@Piasy
Copy link
Owner

Piasy commented May 17, 2020

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!

@moodcal
Copy link

moodcal commented May 18, 2020

A simple solution is to use the mUri's extension directly :-)

@Piasy
Copy link
Owner

Piasy commented May 18, 2020

That's very easy to break, many social media don't have extension in their image url.

@moodcal
Copy link

moodcal commented May 18, 2020

Yeah, but it's understandable to keep the same extension as the original file

@gongshoudao
Copy link

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants