'Android 11 video upload from gallery

I want to upload videos in my android device gallery to AWS S3. I want to trim and compress the video before uploading. When I try to upload it from Android devices having API level 10 onwards it throws file access exception.

I'm looking for a long-term solution, so I need something without requestLegacyStorage, preserveLegacyStorage and MANAGE_EXTERNAL_STORAGE permission.

Now I'm following this steps to upload videos;

  1. Copy the original file to app's own scoped storage directory
  2. Trim the required portion from video and compress it.
  3. Upload this compressed copy to AWS

It works fine in this method. But when it comes to large video files it'll take long time even for copying the file to scoped storage of the app.

Is there any alternative solution for bypassing this copying step by directly trim the original video and save that trimmed video part in app's own directory?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source