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

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

问题描述

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

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

文件已成功上传,但文件名未更新.它使用默认文件名上传,即Untitled".

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 APIv3 上传 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 文件上传到谷歌驱动器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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