upload zip file to google drive using curl

╄→гoц情女王★ 提交于 2019-12-01 09:32:47

问题


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".

I am using below command.

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

回答1:


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"

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



来源:https://stackoverflow.com/questions/45878753/upload-zip-file-to-google-drive-using-curl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!