根据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);