4

I'm trying to add title info when uploading file but request not giving error and upload success still title not setting. Also when i tried to set permissions with post multipart it was not working too therefore used post json request. I can't use json when uploading file so i don't know how to handle this.

Source code (Upload method): https://github.com/ShareX/ShareX/blob/master/UploadersLib/FileUploaders/GoogleDrive.cs

I'm using this same post multipart codes for around 25 different uploading services and it only not works in Google Drive.

When i add "?uploadType=multipart" to url it giving this error:

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "badContent",
    "message": "Unsupported content with type: application/octet-stream"
   }
  ],
  "code": 400,
  "message": "Unsupported content with type: application/octet-stream"
 }
}

But content type is:

multipart/form-data; boundary=--------------------8d110c071a9b453

So i can upload files successfully also i can set permission with json request but unable to set title.

Also i'm wondering is it possible to set permission in upload request or second request is always required?

2
  • You need to be very precise in your construction of the headers the best thing is to test your request using the playground developers.google.com/oauthplayground then you can fine tune it. Use developers.google.com/drive/web/manage-uploads for some examples. The link you posted is dead, so there is not enough information to post a solution Commented Jul 14, 2015 at 9:14
  • Just used multipart/related protocol because API was not supporting multipart protocol properly. There was no problem in headers or multiparts creation because more than 40 uploaders was using these codes. I don't understand why it was requiring multipart/related and creating too much work to us too. Commented Jul 14, 2015 at 13:18

1 Answer 1

2

Instead i used https://www.googleapis.com/drive/v2/files/{fileid} for set title and parents.

This require second request but have no choice, because can't set metadata while uploading.

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

Comments

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.