【发布时间】:2016-07-09 12:04:51
【问题描述】:
我想直接从 AngularJS 上传大于 32MB 的文件到 GCS
当文件大小小于 32MB 时,我可以使用下面给出的代码成功上传到 Blobstore。
$http.post(uploadUrl, $scope.formData, {
withCredentials: true,
headers: {'Content-Type': undefined},
transformRequest: angular.identity
});
当我尝试使用 url https://storage.googleapis.com/bucket-name/filename 上传文件时,出现以下错误。
Credentials flag is 'true', but the 'Access-Control-Allow-Credentials' header is ''. It must be 'true' to allow credentials. Origin 'http://localhost:8080' is therefore not allowed access.
当我删除 http 帖子中使用的标志 withCredentials: true 时,我得到的响应为 403,没有给出错误详细信息。
我已经为上传存储桶设置了上述的 cors
[{"maxAgeSeconds": 3600, "method": ["GET", "POST", "HEAD"], "origin": ["http://localhost:8088"], "responseHeader": ["Content-Type"]}]
如何在服务器中启用Access-Control-Allow-Credentials标志?
【问题讨论】:
标签: angularjs google-app-engine google-cloud-storage