Hi everyone!
I have a column that stores images or documents uploaded by users (stored in Google Drive). I want to use the action "Data: Add a new row to another table using values from this row" to duplicate a record including the file, but I donโt want to just copy the link. I want to actually duplicate the file itself in Google Drive and store the new file link in the new row. Is this possible within AppSheet?
Any guidance, examples, or suggestions would be greatly appreciated!
Thanks in advance
This can be done with some Appscript and an Appscript Task in Appsheet.
There are some things you need to decide though such as where are you going to store the copy on Google Drive? A folder in your drive? A shared drive?
You also need to know the location AND the exact filename of where the original file upload is. I would strongly suggest that you use appsheet formula to create the filename behind the scenes for the uploaded file as you will then know this. I usually use the KEY (Uniqueid()) of the row that is being uploaded to.
The method in script you will use is to give the DriveApp service the folderid of where users upload files to. You will pass the name of the file uploaded to the appscript task from appsheet and then your script will look for the name of this file in the provided folderid. Once it has found this file you will be able to makeCopy() with a filename of your choice and put that copy in a folder of your choice. You can then return the fileid and the fileurl of the copied file back to appsheet where it can be stored in your newly copied row.
Please let me know if all that makes sense and you know how to prepare. I will then provide some script for you and a few screenshots.
Hi @scott192 , thank you very much for your prompt response. I truly appreciate it.
The file operation will be done on a drive thatโs been shared with me, since Iโm not the owner of the app but just a co-author.
As for the folder and the file naming convention, Iโm following whatโs already been defined by AppSheet. For example, hereโs a URL from the image column: attachment_Images/04C8B9B7.image.091508.png.
Would you mind explaining in more detail how the technical process should be handled?
User | Count |
---|---|
15 | |
12 | |
9 | |
8 | |
4 |