Download images from google drive

Hi all,

I have a question about download images by using google drive.
it download some files ok but sometimes it download 1.08 kb
FileByFile_Drive.aia (32.5 KB)
Is there something wrong in my blocks

Thanks

1 Like

Perhaps you should follow this guide, Osama...:

HOWTO: Google Drive - Multiple Files Download (file by file)

Hello Tim,
Please check what is wrong in my block.It is the same problem. it just come kb 1.08
Fetch_604_pages.aia (7.8 KB)

This is link of google sheet:

This is link of folder:

https://drive.google.com/drive/u/0/folders/0B6tIqrqfHzcnS3RRbjJBZVZZa3c

Thank you so much Tim.

@powerusers - for info

OK. Interesting.....

I have worked through your aia and fixed a few problems, the "app" works as it should now.
(For reference only: Fetch_604_pages_revised.aia (7.5 KB) )

However, Google have decided that it doesn't like the automated process for downloading files from a public source. I put a url to one of the files to download in my browser, and after some little time it returned this page:

I then clicked on the Google Help link to get this:

Google is blocking the download, but the "app" still tries to save and make a file, hence it creates one with the correct file name, but an empty file of 1.08kb. I have not seen this before, I am guessing this is something new from Google to prevent automated traffic etc.

How to fix this? You have two choices.

  1. If you want to continue to store your files on Google Drive, then you will need to download the files "as you", therefore the requirement would be to write a google apps script("as you") which will perform the download function (When working with google app script web apps, make sure you always create a new version and publish if you make any changes to the script).

Get or Download a Private Image from Google Drive
(this guide works for one file, the script would need developing for multiple files - you do not want to be making 600 script calls!!)

  1. Host your files on your own server somewhere, then follow Taifun's file by file procedure in your app.

File By File from Server

Thank you, Google, for protecting us from ourselves, once again [sarcasm] :imp:

1 Like

Hi Tim,

I'm really sorry to bother you too much.

I choosed the first one and I tried to develove the htiml in order to download file by file seperatelly for all 604 pages but I don't have an experiance in html enough.
Do you have any idea about that dear Tim.
Thank you so much for help

  1. It is javascript, not html
  2. Do some research and learning
    https://developers.google.com/apps-script
  3. Follow the guide above, try to do just one file, get that working, then develop on from there.

Your blocks should look like this(don't forget to add the permission for WRITE_EXTERNAL_STORAGE):

BLOCKS

Create the web app as it is.

It could take a very long time to download all 600+ images, especially if the user is using data and not wifi.

Also, you should rename your first 99 files so that they sort properly e.g. :
page1.jpg > page001.jpg
page2.jpg > page002.jpg
page33.jpg > page033.jpg
page95.jpg > page095.jpg

Hi Osama,

you also can use the 2nd approach to download several files one by one from Google Drive, see also Q3, Q4 and Q5 there App Inventor Tutorials and Examples: Webprefetch File by File | Pura Vida Apps

you also can check, it downloading one or more zipped files would be more efficient... after downloading the zipped files then just unzip them.... App Inventor Extensions: Zip/Unzip | Pura Vida Apps

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

Hello Tim,
I tried to find any example for download several files one by one from Google Drive in Q3, Q4, AND Q5 but there isn't any example.

I don't know how to download zip file from Google Drive.

Please help me.

Thank you so much.

Osama

I put together all the blocks you need in my post above

and you have already the google apps script (you need to put your FolderID into it when you build it). I can't do this part for you because it has to be created on your google account.

Remember when making any changes to an apps script web app

1 Open the script project
2 Go to Publish
3 Deploy as Web App
4 Project version: - select New from the dropdown
5 Execute the app as: your google account address (email)
6 Who has access to the app: Anyone, even anonymous
7 Press the Update button

You have to do this EVERY TIME you change your script

More info an creating a web app

Hello Tim,

I think zip and unzip file is much easier than make srcipt.
I zipped all images 604 into one zip file. And I upladed it into Google drive.
I just need to know how can I download zip file from google drive.
This is link of zip file:

Please advise me Tim.
Thank you so much

If your file is private just use this (ignore the part about images, the script will do the work and use the extension from Juan Antonio to convert the base64 back to a binary file):

Get or Download a Private Image from Google Drive

If you want to have your zip file public, and risk Google blocking downloads because of using up your quota, then use the web component to download the file:

https://drive.google.com/uc?export=download&id=<The FileID of your ZIP file>

I estimate your zip file will be somewhere between 30 and 60mb in size

Have you considered doing it this way?

Yes, I have.
the zip file is just MB 32.

Hello Tim,
Ok. Please forget about zip and unzip file because there is risk.

Now I try by using private download

Please give me some tips what to do next.
Thank you so much for great job to help me and encourage me.

You do not need to put that html file in your google apps script, that is for the AppInventor app webviewer and should be saved as a file in the assets..

Hello Tim,
I'm sorry. I missed understanding you. I will try to use Download a Private Image.
I tried to test the Get or Download a Private Image from Google Drive. for a single image and change the path but it seems that I confused.

Let us take a step back.....

Are you hoping to download your zip file of all the images, or to download each image file by file using the "private" method ?

Hello Tim,
Please forget about zip and unzip file because there is risk as you said.

Now sure I want to download each image file by file using the "private" method.
Please help me Tim.
Thank you so much.