Download images from google drive

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.....

I have replaced the code but when I publish and deploy as web it comes error:

You need a curly bracket at the end, on line 12

}

You may also need to add the Drive api to your resources:

driveapi2

I have done Every as you had told me. But still there is soemthing is missing.


[Fetch_FILE_BY_FILE.aia|attachment]
Please see my .aia
Fetch_FILE_BY_FILE.aia (18.5 KB)

OK, let me test

Did you add the Drive API ?

I am getting a bad-base64 error.

Did you republish the app to a new version, do it anyway

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

Also check your script url again, did it change when you put in the new code ?

I am sure I have done all steps
But I might missed something in my blocks or copy in wrong way.

I tried to run the script in web and there is error

It works !! :+1:

Use this aia project

Fetch_FILE_BY_FILE_revised.aia (18.6 KB)

(there were a few errors in your aia file which have been fixed.)

Please note that I have set the NumberOfFiles local variable to 5 for testing purposes, you will need to put the length of list block back in to attempt a download of all 600+ files, when you are ready

While testing, remember to run tinydb1.ClearAll after downloading files in order to reset the firstrun tag.

Yes. it works now.
Thank you so much for the great job.
You are really a very helpful man.
Good luck.

Just to finish this off, for others that may follow, a link to:

HOWTO: Create a Google Apps Script Web App bound to a Spreadsheet