Download images from google drive

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.

Then use the blocks i provided for you earlier in the topic!

Hello Tim,
Thank you for help.
I made the block as you told me. I checked it but it doesn't work properlly
This is my pages link : https://drive.google.com/drive/u/0/folders/0B6tIqrqfHzcnS3RRbjJBZVZZa3c
This is my sheet link: https://docs.google.com/spreadsheets/d/1EmuBTTjGigWBRBsafkHipmWCntE1fTDMm4djBkVWTCM/edit#gid=0
Fetch_FILE_BY_FILE.aia (18.5 KB)

What is the url for your web app - you are using mine!

Should look like this:

https://script.google.com/macros/s/AKfycbyrq60eRrlGsFzb7tUE9zLJGp7nA/exec

You need to rename all your actual files from 1 - 100 as recommended in your folder, because the spreadsheet which you have created indicates 001,002,098,099....

Hello Tim,
I have edited all my files and I used my url for my web app:

https://script.google.com/macros/s/AKfycbxttnlirNN5WjBPjnkFDs6sSS7yVdzj16C2WeKVdo9DAgtO-EzP/exec

But still it doesn't download any file at all.

Your web app is not working. Show me what you put in it.

Also

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

I have done all 7 steps as you told me Tim.

Fetch_FILE_BY_FILE.aia (18.5 KB)

That is not the web app code. That is a script to create the spreadsheet (I guessed you built your spreadsheet by hand!)
This is what your web app script should look like:

also so you can copy and paste:

function doGet(e) {
var imgID = e.parameter.imgID;
var bytes = DriveApp.getFileById(imgID).getBlob().getBytes();
return ContentService.createTextOutput(Utilities.base64Encode(bytes));

}

function doPost(e) {
var imgID = e.parameter.imgID;
var bytes = DriveApp.getFileById(imgID).getBlob().getBytes();
return ContentService.createTextOutput(Utilities.base64Encode(bytes));
}

Delete the other one to avoid confusion, given you have your spreadsheet set up. We can come back to that later.....