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

How to download a video using Uri as path? #297

Closed
denisnumb opened this issue Oct 1, 2024 · 1 comment
Closed

How to download a video using Uri as path? #297

denisnumb opened this issue Oct 1, 2024 · 1 comment

Comments

@denisnumb
Copy link

denisnumb commented Oct 1, 2024

I am developing an application with Android ≧ 10 target system.

And if I try to get the directory to save the video like this:

File downloadsDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);

This will work, but after clearing the application data or after restarting the smartphone, the application will no longer have access to the downloaded videos.

Because in Android ≧ 10, to work with external files you need to use SAF, that is, Intent.ACTION_OPEN_DOCUMENT_TREE and registerForActivityResult, then as a result I get a Uri as the user-selected path, which I cannot correctly convert into a full path for transmission to YoutubeDL.

How to download a video with only the Uri?


A temporary solution is to download the file to cacheDir and then move it to the desired directory

@JunkFood02
Copy link
Collaborator

see #174

This will work, but after clearing the application data or after restarting the smartphone, the application will no longer have access to the downloaded videos.

That's true for clearing the app data or uninstalling the app, but a reboot won't invalidate the file access afaik

to download the file to cacheDir and then move it to the desired directory

Yes, and this is the only way i'm afraid

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

No branches or pull requests

2 participants