2
votes

I am using Google Drive api's to upload the new file....While doing so, I get the following error

You cannot upload content to files of type application/vnd.google-apps.drive-sdk.

I am able to upload the file when I set the mimeType as null...If I set the mimeType as application/octet-stream, I get the above error Can anyone let me know what are the mimeTypes which can be set?? and also what does that error actually means??

TIA, VijayRaj

1
Can you give us more information as to how you are uploading the files? Are you first uploading the metadata, and the the media in a separate request or are you sending both metadata and media in the same request?Alain
This is the code I am using.... com.google.api.services.drive.model.File body = new com.google.api.services.drive.model.File(); body.setTitle(filename); body.setMimeType(<mimetype>); FileContent mediaContent = new FileContent(<mimetype>, file); resultFile = service.files().insert(body, mediaContent).execute();VijayRaj

1 Answers

1
votes

I suspect you are getting this error because you did not register the MIME type application/octet-stream as a MIME type of your application in the Google APIs Console project. If you update those settings with the correct MIME type(s) and extensions, this should work fine. The code from your comment seems correct.