android - 如何将文件重命名为 google drive rest api?改造2

标签 android rest request rename retrofit2

谷歌文档里没有写关于它的,我用的是retrofit 2。求助。写出应该发什么请求,传什么参数

接口(interface):

 @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"}

关于android - 如何将文件重命名为 google drive rest api?改造2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43705453/

相关文章:

android - Android 上按 ABI 拆分 Assets

android - 使用 Vision API 扫描反色二维码

Javascript:Cloud Firestore 合并正在替换数据

java - 如何模拟 Spring WebClient 和构建器

来自 Application 类的 Android Marshmallow 权限

java - 处理 fragment ListView 时出错,找不到符号 'list'

java - TextView 中不区分大小写的突出显示

android - Android 和 App Engine 实际上是如何通信的?

java - 改造请求中如何设置界面参数

firefox - 检查网络响应是来自服务器还是来自 Firefox 缓存