如何将文件重命名为 google drive rest api?改造2
How do I rename a file to google drive rest api? Retrofit2
文档里Google没有写关于它的,我用的是retrofit 2。求助。写应该发什么请求,传什么参数
接口:
@PATCH("drive/v3/files/{fileId}")
@Multipart
Call<ResponseBody> renameFileGoogle(
@Path("fileId")String fileId,
@Part MultipartBody.Part metaPart
);
调用方法:
public void renameMetod(String id, String title) {
String content = "{\"name\": \"" + title + "\"}";
MediaType contentType = MediaType.parse("application/json; charset=UTF-8");
MultipartBody.Part metaPart = MultipartBody.Part.create(RequestBody.create(contentType, content));
Call<ResponseBody> renameRequest = server.renameFileGoogle(id, metaPart);
renameRequest.enqueue(new Callback<ResponseBody>()...
它在文档中 https://developers.google.com/drive/v2/reference/files/patch
您需要发送 HTTP PATCH 请求
PATCH https://www.googleapis.com/drive/v2/files/{fileId}
RequestBody:
{"title":"newTitle"}
对于版本 3
https://developers.google.com/drive/v3/reference/files/update
PATCH https://www.googleapis.com/drive/v3/files/{fileId}
RequestBody:
{"name":"newTitle"}
文档里Google没有写关于它的,我用的是retrofit 2。求助。写应该发什么请求,传什么参数
接口:
@PATCH("drive/v3/files/{fileId}")
@Multipart
Call<ResponseBody> renameFileGoogle(
@Path("fileId")String fileId,
@Part MultipartBody.Part metaPart
);
调用方法:
public void renameMetod(String id, String title) {
String content = "{\"name\": \"" + title + "\"}";
MediaType contentType = MediaType.parse("application/json; charset=UTF-8");
MultipartBody.Part metaPart = MultipartBody.Part.create(RequestBody.create(contentType, content));
Call<ResponseBody> renameRequest = server.renameFileGoogle(id, metaPart);
renameRequest.enqueue(new Callback<ResponseBody>()...
它在文档中 https://developers.google.com/drive/v2/reference/files/patch
您需要发送 HTTP PATCH 请求
PATCH https://www.googleapis.com/drive/v2/files/{fileId}
RequestBody:
{"title":"newTitle"}
对于版本 3 https://developers.google.com/drive/v3/reference/files/update
PATCH https://www.googleapis.com/drive/v3/files/{fileId}
RequestBody:
{"name":"newTitle"}