2

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

2
  • 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? Commented Jun 4, 2012 at 15:45
  • 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(); Commented Jun 5, 2012 at 6:08

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

4 Comments

Can we write a content to the shortcut file i.e, without mentioning the mime type??
Shortcut-type files are meant to be shortcut only (e.g no blob content). If you need to add content to a file, you need to specify a MIME type when inserting it.
Can we update these shortcut files?? I tried to update these shortcut files but their last modified time remains unchanged..
I tried to update the modified date for the shortcut files using the code Date d=new Date(); DateTime now = new DateTime(d.getTime()); file.setModifiedDate(now); while doing so I get Bad request error...any pointers??

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.