Jaex
Jaex

Reputation: 4304

Problems using multipart post request when uploading

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?

Upvotes: 4

Views: 1950

Answers (1)

Jaex
Jaex

Reputation: 4304

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.

Upvotes: 2

Related Questions