[英]How to upload an Excel sheet/workbook DIRECTLY from Jupyter Notebook to Amazon's S3?
[英]How to directly upload files from google drive to amazon s3?
我想直接將一些文件從谷歌驅動器上傳到亞馬遜 s3,但無法這樣做。
我不知道,如何將文件從谷歌驅動器直接上傳到亞馬遜 s3。
我嘗試使用 python 和 google api 獲取下載鏈接。
但是當我嘗試上傳到亞馬遜 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)
})
錯誤
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.
誰能告訴我,我該如何解決這個錯誤?
設法找到答案並將其作為答案發布給正在尋找相同答案的任何人:
首先,您需要一個可下載的鏈接,您可以使用文件 ID 構建該鏈接:
這里是:
"https://www.googleapis.com/drive/v3/files/"+file.id+'?alt=media'
然后您可以使用您的 google 訪問令牌發出 GET 請求:
'Authorization','Bearer '+accessToken
這樣你就可以從谷歌驅動器下載文件,你可以上傳到s3。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.