You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the saveMedia method in the Capacitor-Media plugin returns only the file's absolute path (file://). However, Android restricts the use of file:// URIs for sharing files between apps, requiring a content:// URI instead. This feature request proposes adding support for returning a content:// URI when saving media on Android.
Use Case
File Sharing Between Apps:
When media is saved via saveMedia, it is often shared with other apps. Returning a content:// URI would make it easier to share files securely without triggering a FileUriExposedException.
Compliance with Android Scoped Storage:
content:// URIs align with Android's Scoped Storage policies, ensuring compatibility with modern Android versions.
Reduce Overhead for Developers:
Currently, developers need to manually generate a content:// URI from the returned file path. Returning a content:// URI directly simplifies the workflow.
Suggested Implementation
Android Implementation
Modify the saveMedia method to return both the absolute file path (file://) and the content:// URI.
No breaking changes are introduced. The existing filePath property remains, and a new property contentUri is added for additional functionality.
Expected Behavior
Existing functionality: The method continues to return the absolute file path (filePath) for backward compatibility.
New functionality: Adds the contentUri field to provide a content:// URI for better compatibility and ease of use.
Platform Support
Android: Full support for content:// URIs using FileProvider.
iOS: Not applicable, as iOS doesn't use content URIs.
Conclusion
Adding support for returning content:// URIs in saveMedia enhances the Capacitor-Media plugin by aligning it with modern Android storage policies. It simplifies file-sharing workflows for developers and ensures better compatibility with other apps and Android versions.
If you need further clarification or additional details, feel free to ask! 😊
The text was updated successfully, but these errors were encountered:
@stephan-fischer what specific use case are you trying to solve? I believe that the standard for apps accessing images from other apps is to use the Photo Picker API, but I might be misunderstanding what you're trying to accomplish here. I don't believe just using a content:// URL magically gives an app access to images that are scoped to another app, but again, might be missing something.
Description
Currently, the
saveMedia
method in the Capacitor-Media plugin returns only the file's absolute path (file://
). However, Android restricts the use offile://
URIs for sharing files between apps, requiring acontent://
URI instead. This feature request proposes adding support for returning acontent://
URI when saving media on Android.Use Case
File Sharing Between Apps:
saveMedia
, it is often shared with other apps. Returning acontent://
URI would make it easier to share files securely without triggering aFileUriExposedException
.Compliance with Android Scoped Storage:
content://
URIs align with Android's Scoped Storage policies, ensuring compatibility with modern Android versions.Reduce Overhead for Developers:
content://
URI from the returned file path. Returning acontent://
URI directly simplifies the workflow.Suggested Implementation
Android Implementation
Modify the
saveMedia
method to return both the absolute file path (file://
) and thecontent://
URI.Example Return Value
When the method resolves successfully, the returned object could look like this:
API Changes
No breaking changes are introduced. The existing
filePath
property remains, and a new propertycontentUri
is added for additional functionality.Expected Behavior
filePath
) for backward compatibility.contentUri
field to provide acontent://
URI for better compatibility and ease of use.Platform Support
content://
URIs usingFileProvider
.Conclusion
Adding support for returning
content://
URIs insaveMedia
enhances the Capacitor-Media plugin by aligning it with modern Android storage policies. It simplifies file-sharing workflows for developers and ensures better compatibility with other apps and Android versions.If you need further clarification or additional details, feel free to ask! 😊
The text was updated successfully, but these errors were encountered: