如何将文件重命名为 google drive rest api?改造2 [英] How do I rename a file to google drive rest api? Retrofit2
本文介绍了如何将文件重命名为 google drive rest api?改造2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在谷歌文档中没有写到,我使用的是retrofit 2.帮助.写出应该发送什么请求和传输什么参数
In the Google documentation about it is not written, I use retrofit 2. Help. Write what request should be sent and what parameters to transmit
界面:
@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 请求
You need to send an HTTP PATCH request
PATCH https://www.googleapis.com/drive/v2/files/{fileId}
RequestBody:
{"title":"newTitle"}
对于版本 3https://developers.google.com/drive/v3/reference/files/update
PATCH https://www.googleapis.com/drive/v3/files/{fileId}
RequestBody:
{"name":"newTitle"}
这篇关于如何将文件重命名为 google drive rest api?改造2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文