samedi 27 juin 2015

Upload file to a specific Google Drive folder

This is my code used to upload my file to a Google Drive folder following this and this documentation:

url = 'http://ift.tt/1nDTxXQ'
xhr = new XMLHttpRequest()
file.parents = ['0Byw-VOFo8yZ0a3NmSGpTajJmc0E'] # ID of the folder
xhr.file = file
xhr.open 'post', url, true
xhr.setRequestHeader 'Authorization', "Bearer #{ token }"
xhr.onreadystatechange = (event) ->
  if @readyState is 4 and @status is 200
    console.log @responseText
    callback null, event
xhr.send file

Unfortunately, the file is always uploaded to the root folder. I've also tried this: file.parents = [{ id: '0Byw-VOFo8yZ0a3NmSGpTajJmc0E' }]. But it still doesn't work.

Am I missing anything?

Aucun commentaire:

Enregistrer un commentaire