Reputation: 103
I am having a few issues with the Google Drive node.js library. I am trying to upload a picture to my google drive, I have authenticated previously hence the 'oauth2Client' object. This is taken nearly like for like from the example on the google docs.
var service = googleApi.drive('v3');
var fileMetadata = {
'name': 'jpeg-home.jpg'
};
var media = {
mimeType: 'image/jpeg',
body: fs.createReadStream('./temp/downloads/jpeg-home.jpg')
};
service.files.create({
auth: oauth2Client,
resource: fileMetadata,
media: media,
fields: 'id'
}, function (err, file) {
if (err) {
console.error(err);
return false;
} else {
console.log('File Id: ', file.id);
return true;
}
});
The response I am getting is an error of:
Error: Invalid multipart request with 0 mime parts.
I have done some searching and couldn't find anything so any help would be appreciated. Cheers in advance.
Upvotes: 2
Views: 1862
Reputation: 7866
I'm the current maintainer of both google-auth-library
and googleapis
. Please, please make sure that you do not install your own version of google-auth-library
along side googleapis
. googleapis
comes with a compatible version of google-auth-library
built in. If you try to install your own version - it could break in weird, unpredictable ways.
The right thing to do here is to delete google-auth-library
from your package.json, run npm install
, and then use google.auth.OAuth2
for your requests. Hope this helps!
Upvotes: 1
Reputation: 1
I solved this problem by upgrading google-auth-library
to latest version (1.3.2 at this moment).
In the official quickstart, it specifies to install the library like this:
npm install google-auth-library@0.* --save
Just do it like this to install the latest:
npm install --save google-auth-library
Notice that this upgrade has some breaking changes, so you need to upgrade your code of authorization like specified here
Upvotes: 0
Reputation: 1615
The samples in the docs https://developers.google.com/drive/v3/web/manage-uploads appear to have been broken since version 25 of the googleapis package.
Reverting to [email protected] will resolve the problem until either the documentation or later package code is fixed.
Upvotes: 0