Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

upload zip file to google drive using curl

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
like image 822
Saran Brar Avatar asked Aug 25 '17 09:08

Saran Brar


1 Answers

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 "[email protected];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.

like image 130
Tanaike Avatar answered Sep 22 '22 15:09

Tanaike