title: How to fix "Blob object must have non-null data for this operation. (line 6, file "Code")" in google script
body: <p>I want to create a duplicate file and then send it via email, but I'm getting error:</p>
  
  <blockquote>
    <p>Blob object must have non-null data for this operation. (line 6, file "Code")</p>
  </blockquote>
  
  <p>I've tried to change: </p>
  
  <pre><code>var duplicatedFileId = sourceFile.makeCopy(sourceFile+" copy", sourceFolder).getId(); 
  </code></pre>
  
  <p>Into:</p>
  
  <pre><code>var duplicatedFileId = sourceFile.makeCopy(sourceFile+" copy", sourceFolder).getId().toString();
  </code></pre>
  
  <p>But I got another error.</p>
  
  <pre><code>function myFunction() {
    var sourceFolder = DriveApp.getFolderById("1DiqneJbyPN90SvE7uGaesdrd7Po6NJLl");
    var sourceFile = DriveApp.getFileById("1qAabbU8MlWmV8J1rdI5A8eEvUPLXAqKnz6fp1vxUOzQ");
    var duplicatedFileId = sourceFile.makeCopy(sourceFile+" copy", sourceFolder).getId();
    var duplicatedFile = DriveApp.getFileById(duplicatedFileId);
    GmailApp.sendEmail("someone@gmail.com", "Testing attaching a file", "This is a test email", {
      attachments:[duplicatedFile.getAs(MimeType.GOOGLE_DOCS)],
      name:sourceFile+" copy"
    });
  }
  </code></pre>
  
  <p>I expected the duplicate file to be sent, but I got error:</p>
  
  <blockquote>
    <p>Blob object must have non-null data for this operation. (line 6, file "Code").</p>
  </blockquote>