title: Upload image from URL to Google Drive through Google Drive API Javascript
body: <p>I am new in Javascript and sorry if my question seems lame to you. I want to upload an image from my website to my Google Drive. I have successfully implemented the Authentication and Folder creation part, but I am confused about the uploading process.<br />
  Say this is my code for creating a folder inside Google Drive:</p>
  <pre><code>function createFolder(folderName) {
    var parentId = 'xxxxxxx';//some parentId of a folder under which to create the new folder
    var fileMetadata = {
      'name' : folderName,
      'mimeType' : 'application/vnd.google-apps.folder',
      'parents': [parentId]
    };
    gapi.client.drive.files.create({
      resource: fileMetadata,
    }).then(function(response) {
      switch(response.status){
        case 200:
        var file = response.result;
        console.log('Created Folder Id: ', file.id);
        uploadImage(file.id);
        break;
        default:
        console.log('Error creating the folder, '+response);
        break;
      }
    });
  }
  </code></pre>
  <p>Now I want to upload my image from this url: <code>https://xxxxxx.com</code> into the newly created folder from upper response (<code>file.id</code>)</p>
  <p>This is what I got in Google API documentation, but where should I put/attached my url in it?</p>
  <pre><code>function uploadImage(folderId) {
    var fileMetadata = {
      'name': 'photo.jpg',
      parents: [folderId]
    };
    var media = {
      mimeType: 'image/jpeg',
      body: fs.createReadStream('files/photo.jpg')
    };
    drive.files.create({
      resource: fileMetadata,
      media: media,
      fields: 'id'
    }, function (err, file) {
      if (err) {
        // Handle error
        console.error(err);
      } else {
        console.log('File Id: ', file.id);
      }
    });
  }   
  </code></pre>
  <p>Thanks a lot in advance.</p>