简体   繁体   中英

How to directly upload files from google drive to amazon s3?

I want to directly upload some files from google drive to amazon s3 but unable to do so.

I dont know, how can i directly upload the files from google drive to amazon s3.

I tried getting the download link using python and google api.

but when I try to upload to amazon s3 I'm getting errors:

      axios
      .get("https://drive.google.com/u/0/uc?id="+id+"&export=download", {
        responseType: 'arraybuffer',
        withCredentials: false,
        headers:{
          'Authorization':'Bearer: <access_token>',
          'Content-Type': 'text/plain'
        }
      })
      .then((response:any) => Buffer.from(response.data, 'binary'))
      .then((data:any)=>{
        console.log(data)
      })

EROR

has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Can anyone please tell me, how can i resolve this error?

you got the data from drive then; with aws-sdk package you can create

s3 = new AWS.S3(....)

then use s3.putObjectmethod

Manage to find the answer and posting this as answer for anyone who is looking for same:

First you need a downloadable link which you can construct using file id:

Here it is:

"https://www.googleapis.com/drive/v3/files/"+file.id+'?alt=media'

Then you can make a GET request with your google access token:

'Authorization','Bearer '+accessToken

This way you can download file from google drive which you can upload to s3.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM