使用curl将zip文件上传到Google驱动器 [英] upload zip file to google drive using curl

查看:269
本文介绍了使用curl将zip文件上传到Google驱动器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 curl 将zip文件上传到Google云端硬盘帐户。

I am trying to upload a zip file to Google drive account using curl.

文件已上传成功,但文件名未更新。它以默认文件名即 无标题上传。

The file is uploaded successfully but the filename is not getting updated. It gets uploaded with default filename i.e. "Untitled".

我正在使用以下命令。

curl -k -H "Authorization: Bearer cat /tmp/token.txt" -F "metadata={name : 'backup.zip'} --data-binary "@backup.zip" https://www.googleapis.com/upload/drive/v2/files?uploadType=multipart


推荐答案

Drive API v3 上传zip文件。修改后的curl代码如下。

You can use Drive API v3 to upload the zip file. The modified curl code is as follows.

curl -X POST -L \
    -H "Authorization: Bearer `cat /tmp/token.txt`" \
    -F "metadata={name : 'backup.zip'};type=application/json;charset=UTF-8" \
    -F "file=@backup.zip;type=application/zip" \
    "https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart"

要使用此功能,请在 https://www.googleapis.com/auth/drive 中添加范围。

In order to use this, please include https://www.googleapis.com/auth/drive in the scope.

这篇关于使用curl将zip文件上传到Google驱动器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆