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

Add support to write data to a File using a Uri #114

Conversation

Ma7moudHatem
Copy link
Contributor

Add support to write data to a File using a Uri, where most likely to support scoped-storage enforcement in Android 10+, by using Uri instead of directly writing to File which will cause an exception.

…to support scoped-storage enforcement in Android 10+, by using Uri instead of directly writing to File which will cause an exception
if (parcelFileDescriptor != null) {
mediaMuxer = new MediaMuxer(parcelFileDescriptor.getFileDescriptor(), outputFormat);
} else {
throw new IOException();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe MediaTargetException here as well? Use IO_FAILURE enum value

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@izzytwosheds, already the MediaTargetException with IO_FAILURE will be thrown after throwing the IOException because there is an IOException catch case with the try, else if you prefer to directly throw the MediaTargetException here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha, I see it now. Should we add a helpful message to IOException? Something like "Inaccessible URI" + outputFileUri ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think yes, and it's fixed now

@izzytwosheds izzytwosheds merged commit 16328dc into linkedin:main Apr 20, 2021
@Ma7moudHatem Ma7moudHatem deleted the support-android10-scoped-storage-by-uri branch May 24, 2021 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants