Fail to download audio file from Google Drive

When trying to download a file from Google drive using FileID as described here: https://www.howtogeek.com/747810/how-to-make-a-direct-download-link-for-google-drive-files/.
I have the message: Error 1101: Unable to get a response with the specified URL: https://drive.google.com/uc?export=download&id=1........ when testing with Android Companion or with built application APK.


Here is the screenshot of my project:

And here is the aia:
Download_File_From_Google_Drive_V2.aia (11.0 KB)

Note this aia is working fine with iOS: both companion AND .ipa (see: How is it possible to read asset file with iOS? - #29 by Anke)

Using your aia project (with some adjustments - filescope to App and remove the tinydb blocks) the url downloads the file to my device. So no intrinsic issue with the url.

Audio file plays a ringing bell (proof :wink: )

image

Since you have set DefaultFileScope = Legacy, the path (.ResponseFileName) on Android 11+ must be set to one of the Shared folders (/Download, /Music etc).

See also here:

Thanks a lot for solving this issue. I forgot to modify the DefaultFileScope. I assume we should now always use "App"

That depends on what exactly you want to do. If the file(s) should also be available on Android 11+ in a visible area (directory such as /Music, /Download, Documents,...), DefaultFileScope=Legacy or Shared must be set.

You are right. These files are for my App only, so using App is the right choice for me, but not for all situations.

One last question before closing this topic. Filename on Google drive is: "Cloche_Eglise.mp3"

With iOS, the download file has the "original name": (the one on Google drive): Cloche_Eglise.mp3

While with Android it is renamed and the original name is lost.

Is it a difference between iOS and Android? Or due to App Inventor implementation of the web component?
In any case, would be great to keep the original file name with ANdroid App

Thanks a lot

You have to give the filename in your blocks with responsefilename (this is an AI2 web component quirk)

There are several methods that can be used to get a list of filenames of google drive files from their urls.

1 Like

If DefaultFileScope is set to "App"

the first block save to in the root dir of the ASD, the second in a subfolder /Download in the ASD.

Yes, this is a way to specify the file name. But the app has to know the file name! I was planning to provide only the link to the App, so it does know the file name of the downloaded file.
iOS is able to retreive it from the link! Any reason Android or Web component of App inventor cannot do it?
Otherwise, as uggested by @TIMAI2 it may be possible to use some Google drive API to get this information.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.