title: Uploading a spreadsheet file on Google Drive in Swift
body: <p>I am able to upload an NSMutableString string (separated by commas) as a CSV file to Google Drive in Swift. However, I want to save it as a Google Spreadsheet.</p>
  
  <p>Apparently, they have the "convert" property in Objective-C when you use queryForFilesInsertWithObject method. However, I couldn't find the Swift version of this. I created my query as such:</p>
  
  <p>let query = GTLQueryDrive.queryForFilesCreateWithObject(metadata, uploadParameters: uploadParameters)</p>
  
  <p>Since there is no <code>q.convert</code> property, I tried both of the following statements:</p>
  
  <pre><code>query.q = "convert=true"
  query.q = "convert=YES"
  </code></pre>
  
  <p>However, none of them worked.</p>
  
  <p>I have also tried to have mimeType as <code>application/vnd.openxmlformats-officedocument.spreadsheetml.sheet</code> and <code>application/vnd.google-apps.spreadsheet</code> and they didn't help either.</p>
  
  <p>My code is as follows:</p>
  
  <pre><code>let data = NSMutableString()
  var i = 0
  repeat {
         data.appendString("\(measures[i]), \(SegmentedControlChoiceValues[i])\n")
         i += 1
  } while i &lt; measures.count
  let dataAsString = data as String
  
  let metadata = GTLDriveFile()
  metadata.mimeType = "text/csv"
  metadata.name = "Subject01.bar"
  
  let dataToUpload = dataAsString.dataUsingEncoding(NSUTF8StringEncoding)
  let uploadParameters = GTLUploadParameters(data: dataToUpload!, MIMEType: metadata.mimeType)
  let query = GTLQueryDrive.queryForFilesCreateWithObject(metadata, uploadParameters: uploadParameters)
  
  query.q = "convert=true"
  
  Constants.service.executeQuery(query, completionHandler:  { (ticket, insertedFile , error) -&gt; Void in
  
       if error == nil {
          print("File Saved: " + metadata.name)
          success(createdFileID: insertedFile.identifier)
       } else {
          print("An error occurred" + error.description)
          success(createdFileID: "")
       }
  })
  </code></pre>
  
  <p>I would appreciate any help.</p>