以块的形式上传到Google云端存储错误输出503服务不可用 [英] Upload in chunks to Google Cloud Storage error out 503 Service Unavailable

查看:132
本文介绍了以块的形式上传到Google云端存储错误输出503服务不可用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 jQuery Google Cloud Storage v1beta2 Json API 将文件分块上传到Google云端存储中。我正按照 API文档。

I am trying to upload file in chunks using jQuery and Google Cloud Storage v1beta2 Json API into Google Cloud Storage. I am performing following steps as described in API documentation.

第一步:发布获取UploadId的请求

First Step: Post a request to get UploadId


POST /upload/storage/v1beta2/b/test-bucket-01/o?uploadType=resumable&name=args-master.zip HTTP/1.1
Host: www.googleapis.com
Connection: keep-alive
Content-Length: 0
Accept: */*
Origin: http://www.trial.com
Authorization: Bearer ya29.1.AADtN_UptViwI44N8A3Pg89q3lKS7ZesTqYplm0whTdTJFOj0MHjtp-yM7dB8GzfJk62lIuo


在响应中我得到位置标题,其中包括UploadId

In the response I get location header which includes UploadId


HTTP/1.1 200 OK
Location: https://www.googleapis.com/upload/storage/v1beta2/b/test-bucket-01/o?uploadType=resumable&name=args-master.zip&upload_id=AEnB2UoOYm9JYDAPNPisFKG5yheFdRF8oVaxpRHg62BGGBVr2Ue-sg3fbOmg1Ol-PFSXY60aPcl_hDaJP9176ZF6DPaCDAyDkg
Vary: Origin
Access-Control-Allow-Origin: http://www.trial.com
Access-Control-Expose-Headers: Cache-Control, Content-Length, Content-Type, Date, Expires, Location, Pragma, Server,


第二步:使用UploadId和内容发出请求

Second Step: Put request with UploadId and content


PUT /upload/storage/v1beta2/b/test-bucket-01/o?uploadType=resumable&name=args-master.zip&upload_id=AEnB2UoOYm9JYDAPNPisFKG5yheFdRF8oVaxpRHg62BGGBVr2Ue-sg3fbOmg1Ol-PFSXY60aPcl_hDaJP9176ZF6DPaCDAyDkg HTTP/1.1
Host: www.googleapis.com
Connection: keep-alive
Content-Length: 262144
Cache-Control: no-cache
Content-Range: bytes 0-262143/1361678
Authorization: Bearer ya29.1.AADtN_UptViwI44N8A3Pg89q3lKS7ZesTqYplm0whTdTJFOj0MHjtp-yM7dB8GzfJk62lIuo
Origin: http://www.trial.com


作为回应PUT请求我得到503服务不可用错误。

In response of the PUT request I get 503 Service Unavailable error.


HTTP/1.1 503 Service Unavailable
Access-Control-Allow-Origin: http://www.trial.com
Access-Control-Allow-Credentials: true
Access-Control-Expose-Headers: Access-Control-Allow-Credentials, Access-Control-Allow-Origin, Access-Control-Expose-Headers, Content-Length, Content-Type, Date, Server, Transfer-Encoding


我尝试使用Google Cloud Storage的XML API上传但是也遇到了同样的错误。
请在这里建议出现问题。

I tried to upload in chunks with XML API of Google Cloud Storage also but got the same error. Please suggest what is going wrong here.

谢谢

推荐答案

我得到了解决方案,这是我的错误。正如此处所述,Google非常讲究块大小。

I got the solution it was my mistake. As mentioned here, Google is very particular about chunk size.


块大小限制:所有块的大小必须是256 KB(256 x
1024字节)的倍数,除了完成
上传的最后一个块。如果你使用分块,重要的是保持块大小为
尽可能大,以保持上传效率。

Chunk size restriction: All chunks must be a multiple of 256 KB (256 x 1024 bytes) in size, except for the final chunk that completes the upload. If you use chunking, it is important to keep the chunk size as large as possible to keep the upload efficient.

我发送了一个小于限制的字节,这就是我收到错误的原因。

I was sending one byte less than the limit, that's why I was getting the error.

我仍然感到惊讶Google因为我的错误而不是4XX错误发送了503错误这是误导性的。

Still I am surprised Google was sending 503 error for my mistake rather than 4XX error which was misleading.

希望这会有所帮助。

这篇关于以块的形式上传到Google云端存储错误输出503服务不可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆