I'm working on a quicker way to get data from Google Drive for data entry purposes. I have a bunch of folders with images in them, and I need to get the URL of each image, plus the width and height in pixels (part of the properties of each image).
I've never used the Google Drive API before, so I looked up the documentation. It has a demo app in JS that lists all files in the base directory of the drive. However, I don't know enough to change that to request the files in a certain folder.
The idea is that the user pastes in the ID of a Google Drive folder, and then the JavaScript program returns the link, width and height. The user can then simply paste that into the data entry form.
This is the function to list the files:
function listFiles() {
gapi.client.drive.files.list({
'pageSize': 10,
'fields': "nextPageToken, files(id, name)",
}).then(function(response) {
appendPre('Files:');
var files = response.result.files;
if (files && files.length > 0) {
for (var i = 0; i < files.length; i++) {
var file = files[i];
appendPre(file.name + ' (' + file.id + ')');
}
} else {
appendPre('No files found.');
}
});
}
I've seen how to do it using a URL GET request, but have no idea how to translate that into a gapi.client.drive
request as shown above.
Any help here would be good.