From the course: Google Apps Script for JavaScript Developers

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Creating files

Creating files - Google Docs Tutorial

From the course: Google Apps Script for JavaScript Developers

Start my 1-month free trial

Creating files

- [Instructor] So now that we're able to find files on Google Drive, and open them with Google Docs, let's take a look at how we can save files back to Google Drive. Before we call the Logger, let's go ahead and create a new document. We'll set up a variable called newDoc and we're going to set this equal to DriveApp.createFile. As you can see, there are several different options for us to create files. We can use a blob, which is the raw data for a file. We could also simply create a file by a name and passing in content, or we can use the mimeType in order to create a specific type of file extension. Let's take a look at the last option. Here, we're going to give our file a name. So let's go ahead and replace name with a string, markdown-test, and we'll call this .md, which is the extension for markdown files. For the content, we'll simply pass in the text that we took out from the document in the previous line of code. And for the mimeType, we're going to use an enum in order to…

Contents