BUY FULL SOURCE CODE
Welcome folks today in this blog post we will be uploading file to google drive using cURL bash
script in visual studio code using oauth2 and access token. All the steps are shown below.
Get Started
In order to get started you need to open the visual studio code
and we need to make a uploadFile.sh
file as shown below
uploadfile.sh
1 2 3 4 5 |
curl -X POST -L \ -H "Authorization: Bearer ##ACCESSTOKEN##" \ -F "metadata={name :'index'};type=application/json;charset=UTF-8" \ -F "file=@index.zip;type=application/zip" \ "https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart" |
As you can see in the above bash
script we are making a cURL
post request to the oauth2 endpoint where we need to add the authorization
header inside that we need to provide the access token. So copy paste your access token from the OAuth2 Playground as shown below And then we need to provide the metadata of the uploaded file such as the name of the file and the mimetype. In this case as you can see we are uploading a zip
file that’s why we are providing the mimetype to be application/zip
and then we are providing the url at the last. So now we need to run this bash
script inside the visual studio code as shown below
Get Access Token From OAuth2 Playground
And now we need to select the git bash
terminal as shown below in visual studio code
As you can see that after executing the bash
file we get a response from the google drive
api which includes the id of the uploaded file and as you can see the zip
file is successfully uploaded to google drive.
BUY FULL SOURCE CODE