簡體   English   中英

使用可恢復上傳 url 在 React js 中上傳文件在谷歌雲存儲中失敗,拋出 CORS 策略錯誤

[英]Uploading file in react js with resumable upload url is failing in google cloud storage, throwing CORS policy error

I am trying to upload blob in react js with resumable upload url in google cloud storage, but it keeps failing with the error "Request failed with status code 308" and "from origin ' http://localhost ' has been blocked by CORS policy :請求的資源上不存在'Access-Control-Allow-Origin' header。”

// fileBlob is converted from canvas -> dataUrl(jpeg) -> blob

const headers = {
                'Content-Type': 'image/jpeg',
            };
const response = yield axios.put(resumable_upload_url, fileBlob, {headers});

誰能指出我在這里缺少什么,非常感謝!

Getting HTTP response code 308 in response to a query of the resumable session URI indicates you need to continue uploading the file - see https://cloud.google.com/storage/docs/performing-resumable-uploads

這種情況下的響應應該是“308 Resume Incomplete”。 我懷疑您看到的“請求失敗”消息是由您正在使用的庫生成的,並且該庫不理解可恢復上傳協議。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM