使用改造功能在Google云端硬盘中上传多部分文件

时间:2018-07-11 15:18:31

标签: android file-upload retrofit2 multipart google-drive-android-api

根据Google Drive API,分段上传请求的格式为:

POST https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart         
HTTP/1.1
Authorization: Bearer [YOUR_AUTH_TOKEN]
Content-Type: multipart/related; boundary=foo_bar_baz
Content-Length: [NUMBER_OF_BYTES_IN_ENTIRE_REQUEST_BODY]

--foo_bar_baz
Content-Type: application/json; charset=UTF-8

{
  "name": "myObject"
}

--foo_bar_baz
Content-Type: image/jpeg

[JPEG_DATA]

--foo_bar_baz--

我的问题是 如何使用retrofit2创建此请求?

赞:

@POST("/upload/drive/v3/files?uploadType=multipart")
@Multipart
Call<ModelMultipartResponse> sendMultipartUploadReq(@Header("Authorization")String authToken,
@Part MultipartBody.Part metaPart,
@Part MultipartBody.Part dataPart);

0 个答案:

没有答案