The newFile()
method of the Advanced Drive API Service seems to return an object, but not create a file in my Google Drive. I can't find any documentation for this. Here is code that I tried, and the results I got.
function makeNewDoc() {
var file = Drive.newFile();
Logger.log('file ' + file);
file = {one: "value One"};
Logger.log('file ' + file);
Logger.log("file['one'] " + file['one']);
};
The LOGS print this:
file {}
file [object Object]
file['one'] value One
I tried adding a string inside the newFile()
parenthesis:
function makeNewDoc() {
var file = Drive.newFile("some text");
Logger.log('file ' + file);
file = {one: "value One"};
Logger.log('file ' + file);
Logger.log("file['one'] " + file['one']);
for (var key in file) {
Logger.log('key: ' + key);
Logger.log('value: ' + file[key]);
};
};
That didn't produce an error, but it doesn't do anything either. Or I don't know what it's doing.
I've checked my Google drive many times after running the code many times, and there is never a new file in my Drive.
The newFile()
method returns an object, that I can put new properties into, and then enumerate. But other than that, I have no idea what it does, or what use it has.
So, if anyone can tell me what the newFile()
method, of the Drive API does, I would really like to know.
Below is an example how to make a new document with advanced Drive service
I used the answer code and there was a problem when creating the blob as HTML. The below code converts HTML as a string to a blob to be inserted into a document.