我想超过32MB直接从AngularJSAngularJS直接上传到谷歌云存储错误
上传文件的大小更高GCS我能成功上传到Blobstore
当文件大小小于使用下面给出的代码32MB。
$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 POST已使用标志withCredentials: true
,我得到了响应,403,没有错误给出细节。
我已经设置了CORS提到的上传存储 [{"maxAgeSeconds": 3600, "method": ["GET", "POST", "HEAD"], "origin": ["http://localhost:8088"], "responseHeader": ["Content-Type"]}]
如何启用Access-Control-Allow-Credentials
国旗在服务器?
嗨@Eric,谢谢你的回应。我尝试签署的网址,因为我有同样的错误。下载成功但不上传。对于通过blobstore上传,我得到了一个不同的错误,请参考http://stackoverflow.com/questions/38344261/gcs-heap-error-when-file-of-higher-size-was-uploaded。 我无法成功使用'Access-Control-Allow-Origin'标头,修改httpProvider默认标头'$ httpProvider.defaults.headers.common ['Access-Control-Allow-Origin'] ='*';'with'withCredentials :虚假设置没有太大帮助。你能指导我使用标题吗? – SetV
您需要在_server_发送的_response_上设置该标头,而不是来自客户端的请求。因此,在您的Java代码中(我看到的是您链接的其他问题的选择语言),您可以使用'resp.setHeader(“Access-Control-Allow-Origin”,“*”);'。 –
嗨@Eric,我可以坚持你的前两个解决方案。这真的有帮助! – SetV