Reputation: 735
I'm trying to populate a folder with a list of pdf documents I've created using Google Scripts. But when I obtain a PDF file, which I guess is a "Blob", I can't find any functionality to move this file to a specified folder. Ultimately I would like to do something like this:
var temp = target.getAs("application/pdf");
var targetFolder = DocsList.getFolder(TARGET_FOLDER);
temp.addToFolder(targetFolder);
Unfortunately addToFolder is not a thing. Is there anyway to accomplish this? Thanks!
Upvotes: 1
Views: 2283
Reputation: 46822
The folder object has a createFile() method that takes a blob as argument.
use it like this :
var temp = target.getAs("application/pdf");
var targetFolder = DocsList.getFolderById('0B3qS__folder ID____dsMTFZMDQ')
targetFolder.createFile(temp);// this will create the pdf file directly in the folder
Upvotes: 4