Google Drive API uploading a file to team drive in Javascript

前端 未结 4 2235
醉话见心
醉话见心 2021-02-14 19:39

I have been having some issues with the google drive API and teamdrives. I can\'t for the life of me, figure out how to upload a file to team drive.

I\'m able to upload

4条回答
  •  终归单人心
    2021-02-14 19:55

    Try this one from Google uploads
    Also read this: Simple upload

    var fileMetadata = {
          'name': 'photo.jpg'
        };
        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);
          }
        });

提交回复
热议问题