AsynchronousResumableUploadForGoogleDrive
AsynchronousResumableUploadForGoogleDrive copied to clipboard
How can I push the uploads into a unique folder?
I turned this into a simple/pure webapp by replacing this code, and it works great.
`function doGet() { return HtmlService.createHtmlOutputFromFile("index.html"); }
// function main() { // var html = HtmlService.createHtmlOutputFromFile("index"); // SpreadsheetApp.getUi().showSidebar(html); // }`
But, since it uploads the files straight into the root of MyDrive, it can easily be cluttered, and instead I would like each upload to be sent to a specific dated folder inside a base folder. Something like this: /FileUploads/2021-07-01T10:03:15/
So if I upload 10 files in one upload, I want them all there in one dated folder, and the next uplöoad is collected in a new unique dated folder.
How can that be achieved?
I assume most people would like to set the base folder as a constant in the script, since we may all have different names of our base folder, and maybe not everyone would want a dated subfolder, so maybe a "const datedFolder = true" or something would be a good idea?
Simply include folderID in resource variable inside ResumableUploadForGoogleDrive function:
const resource = {
fileName: f.fileName,
fileSize: f.fileSize,
fileType: f.fileType,
fileBuffer: f.result,
accessToken: accessToken,
folderId: "{yourFolderId}" //include this line
};
That worked like a charm, thank you!
Took me one try to realise I should only put the folderId between the "quotes" and not the {also}. I'm learning. :-)
Now if I only knew how to add a new dated/timed sub-folder to the specified folderId, I'd be all set! :-)
Simply include folderID in
resourcevariable insideResumableUploadForGoogleDrivefunction:const resource = { fileName: f.fileName, fileSize: f.fileSize, fileType: f.fileType, fileBuffer: f.result, accessToken: accessToken, folderId: "{yourFolderId}" //include this line };
Hi. Please, help. How can I use folderId from google sheets cell? I use
var folderId= sheet.getRange('B5').getValue();
but if I change folderId: folderId- it doesnt work...