Error while uploading a file using java - google-drive-api

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

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.

Related

Incorrect Mime Type of uploaded file

My html is like this:
<input type="file" id="myfile" />
My javascript code is:
var myfile = $('#myfile');
When trying to upload a .doc file and debugging I can see the type: type: "application/msword"
When doing the same but this time for a .rar when debugging the type is an empty string. Strange because in my local IIS I have correct type and also in Web.Config. I also tested with .abc and same problem.
Tested with Google Chrome and Microsoft Edge.
Any idea ?
The Content-Type of a file upload is determined by the browser not the server, so your IIS settings are irrelevant.
Short of using the File API to read the file and using XHR or fetch to send it (with a whole lot of content-type sniffing in the middle), the content-type the browser picks is beyond your control.

Fiware wirecloud widget upload: error no valid parser found

I want to create a widget and upload it to my FIWARE Mashup Workspace. When I upload my ".wgt" file I get the error:
Error adding packaged resource: Error parsing config.xml descriptor
file: No valid parser found.
How can I get more information about the error?
Is it simply a parsing error, or is something different went wrong (no valid parser found sounds like some service is missing)
Is there a way to check my config.xml file?
This is definitely a configuration error; there is no service missing.
Since your config is in xml, check it with an XML checker, to be sure that no opening/closing tags are missing.
If your wgt is an operator, check that your preferences/endpoints have different IDs. Also, please be sure that all your endpoints use distinct names

Webservice - Multiple file output formats

I need to create one webservice, that is used to download an audio(wav) file from server by taking input one string id. If audio file is not present at server, i need to send error back in json format.
Now the questions is - How to give the extension for downloaded file. I have no prior idea whether response will be success or failure.
What i am doing now is after dowloading a file - i am changing extension of file using Contet-Type header in response according to audio/wav or application/json.
Is there any way to specify file name with extension from server only. i.e downloaded file with name and extension.
You could set:
Content-Disposition: attachment; filename=FILENAME
header on the server side setting a proper xyz.json or xyz.wav filename as described in RFC 2183.

Google drive mime types is not correct (Google thinks that is not PDF?);

I get files from google drive(Using Java)
Everything works! BUT, when I see pdf documents mime type
file.getMimeType()
it is something like that: application/vnd.google-apps.document
it is not application/pdf
Question 1: Why is my pdfs at google drive with mime type application/vnd.google-apps.document
Question 2:
I need to filter my document, in order to get only PDF documents:
but this does not works! Googel thinks that my PDF is "vnd.google-apps.document"!
String mime ="application/pdf"; //works when I set vnd.google-apps.document
String query="'"+id+"'" +" in parents and trashed=false and and mimeType="+mime;
FileList files = service.files().list().setQ(query).execute();
I've been reading a number of comments recently that Drive PDFs have become editable. So my guess is that you uploaded your PDFs with convert=true, and so Drive has converted them to docs. To prevent this, make sure that convert=false.

change Google Drive mimeType on update file

I am trying to make a "Save as" to google drive functionality for my web app. The user is shown the Google Picker and chooses a file to save over. At this point the application is updating the content of the file successfully, but it doesn't change the mimeType of the file being overwritten.
The api reference specifies the following about the mimeType metadata:
"The MIME type of the file. This is only mutable on update when uploading new content [this is the case]. This field can be left blank, and the mimetype will be determined from the uploaded content's MIME type."
I am leaving it blank. In fact, I am doing a simple upload to PUT https://www.googleapis.com/upload/drive/v2/files/{fileId}. And the http request has the Content-Type header set to the mimeType of the file being uploaded. In this case (if this helps) is "application/vnd.ms-project". I also tried adding the uploadType=media parameter to the url, with no success.
I also tried making a multipart update using the Api playground. Sent the metadata content empty {} and the error message was "Unsupported content with type: application/vnd.ms-project". Funny it is unsuported because I did manage to create a new file with the same mimeType, with no problem.
What to do? Any sugestions?
You can't replace an existing native Docs file with a regular blob. The only way to update a docs file with a blob is switching on the Docs conversion which is not possible for a Microsoft Project file.