How to copy a file into a specific folder using DocsList?

前端 未结 4 1683
萌比男神i
萌比男神i 2020-12-22 04:47

I am trying this code to copy a Google spreadsheet into a specific folder

var targetFolder = DocsList.createFolder(\"Testing\");
var mainDocBlob = DocsList.g         


        
4条回答
  •  悲哀的现实
    2020-12-22 05:21

    As mentioned in this other post answer, Google docs are not "files" in the common sense, there is no need to use getBlob to copy them as they don't actually have Blob... (and they don't actually have a 'size' nor use space in your Gdrive for the same reason !)

    Instead you should use (as mentioned in David's answer) addToFolder().

    From this point your file will be moved to the corresponding folder. If you need to have a copy in your root folder then make a copy of it but depending on how you access your files this is not always necessary as you can always explore your Google drive using "All Items" where you see all items in their corresponding folders (and the name of the folder they belong to as well).

    If the file was already in a folder then it will appear as belonging to both folders and again you can choose to leave it as it is or remove it from the original folder using removeFromFolder().

    I know this seems a bit redundant with the other answers but I just hope it makes things more clear on the organization of Google drive.

提交回复
热议问题