apivideo / api.video-flutter-uploader

The official Flutter video uploader for api.video
https://api.video
MIT License
24 stars 2 forks source link

[Bug]: hide additional permission dialog on Android for file access when not needed #24

Open koenmuilwijk opened 3 days ago

koenmuilwijk commented 3 days ago

Version

1.3.0

Environment that reproduces the issue

Is it reproducible in the example application?

Not tested

Reproduction steps

final uploadToken = '...';
final videoId = '...';
final video = await ImagePicker().pickVideo(
      source: ImageSource.gallery, 
      preferredCameraDevice: CameraDevice.front,
      maxDuration: Duration(minutes: 1),
    );
if (video != null) {
  await videouploader.ApiVideoUploader.uploadWithUploadToken(uploadToken, video.path, videoId: videoId);
}

Expected result

When uploading a video an additional permission dialog is displayed on Android. However, in our use case we use ImagePicker for the user to select a file, so we don't need to ask for permission again.

Can we pass a direct link to the selected XFile or File instead of the path as string to prevent this?

Upload video without additional file permission request (already done by ImagePicker().pickVideo(...)).

Actual result

An additional permission request is displayed upon the call to uploadWithUploadToken which doesn't serve any function.

image

Additional context

Android 14 and higher.

Relevant logs output

No response

ThibaultBee commented 19 hours ago

Hi,

On Android 14 a new permission is required to read media. See https://developer.android.com/about/versions/14/changes/partial-photo-video-access

It is just a wild guess but ImagePicker is requesting Manifest.permission.READ_EXTERNAL_STORAGE and the Flutter uploader is requesting Manifest.permission.READ_MEDIA_VIDEO. See https://github.com/apivideo/api.video-flutter-uploader/blob/main/android/src/main/kotlin/video/api/flutter/uploader/utils/Utils.kt#L10 You can check in your built AndroidManifest.xml that you got both permissions. Did you add a read permission (Manifest.permission.READ_EXTERNAL_STORAGE or Manifest.permission.READ_MEDIA_VIDEO) in your application AndroidManifest.xml?

Also, we can't directly use File or XFile because under the hood we are using some native parts. At some point, we will have to get the path from the File or the XFile.