[英]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.我想直接将一些文件从谷歌驱动器上传到亚马逊 s3,但无法这样做。
I dont know, how can i directly upload the files from google drive to amazon s3.我不知道,如何将文件从谷歌驱动器直接上传到亚马逊 s3。
I tried getting the download link using python and google api.我尝试使用 python 和 google api 获取下载链接。
but when I try to upload to amazon s3 I'm getting errors:但是当我尝试上传到亚马逊 s3 时出现错误:
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?谁能告诉我,我该如何解决这个错误?
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:首先,您需要一个可下载的链接,您可以使用文件 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:然后您可以使用您的 google 访问令牌发出 GET 请求:
'Authorization','Bearer '+accessToken
This way you can download file from google drive which you can upload to s3.这样你就可以从谷歌驱动器下载文件,你可以上传到s3。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.