title: Create new file in a folder with Apps Script using Google Advanced Drive service
body: <p>There are four ways to create a new file:</p>
  
  <ul>
  <li>DocsList - Shown as <strong>DocsList</strong> in the Main List. Built in to Apps Script.</li>
  <li>DriveApp - Shown as <strong>Drive</strong> in the Main List. Built in to Apps Script.</li>
  <li>Drive API - Also shown as <strong>Drive</strong> in the Main List.  <em>Must be added</em> to Apps Script.</li>
  <li>DocumentApp - Shown as <strong>Document</strong> in the Main List. Built in, but only creates a document file.</li>
  </ul>
  
  <p>They are all called <strong>services</strong>.  Drive API is called an <strong>advanced service</strong>.  So, which one should you use?  I don't know, it depends.  This question is about the <strong>Drive API</strong> Advanced Service.</p>
  
  <p>I don't want to use 2 or 3 of the services to get the job done.  I'd like to just use one of them.  But to decide which one to use, I need to know the capabilities and options of all of them.  If the simplest and easiest one to use will do everything I want, then I'll use that.</p>
  
  <p>If I can create a new file with Drive API, but then I need to use the DriveApp service to move the file I created with Drive API, to the folder I want it in, then using Drive API in that particular situation is pointless.</p>
  
  <p>I can create a new file in my Google Drive from a Google Apps Script <code>.gs</code> code, but the file gets written to the main 'My Drive'.  I want to write the file directly to a sub-folder. My current code is:</p>
  
  <pre><code>var fileNameSetA = 'someFile.jpg';
  var uploadedBlobA = an image uploaded with a file picker;
  
  var fileTestDrive = {
    title: fileNameSetA,
    mimeType: 'image/jpeg'
  };
  
  fileTestDrive = Drive.Files.insert(fileTestDrive, uploadedBlobA);
  </code></pre>
  
  <p>Even though the code works, I have no idea why the syntax is the way it is, and I can't find documentation that tells me why.  I can find a list of properties:</p>
  
  <p>The <code>title:</code> and <code>mimeType:</code> are Optional Properties as part of the <code>Request Body</code>.  From the example, the Optional Properties are obviously put in a key:value paired object.  So, is the syntax:</p>
  
  <pre><code>Drive.Files.insert(optional properties, content);
  </code></pre>
  
  <p>There are also Required query parameters of:</p>
  
  <p><code>uploadType</code> --> <code>media</code>, <code>multipart</code>, <code>resumable</code></p>
  
  <p>But I don't see any required <code>uploadType</code> parameter designated anywhere in the example code.  So, I don't understand Google's documentation.</p>
  
  <p><a href="https://developers.google.com/drive/v2/reference/files/insert" rel="noreferrer">Google Documentation Insert</a></p>
  
  <p>Is it possible to write directly to a specific drive with Google Advanced Drive service in a Apps Script .gs code file?  How do I do it?</p>