AppEngine BlobStore是否支持上传的块化传输编码(状态411:所需长度)? [英] Does AppEngine BlobStore support Chunked Transfer Encoding for uploads (Status 411: Length required)?

查看:121
本文介绍了AppEngine BlobStore是否支持上传的块化传输编码(状态411:所需长度)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



BlobStore是否支持上传的Chunked Transfer Encoding?



使用setChunkedStreamingMode在Java中使用HttpURLConnection对象,以使用以下代码设置连接来上载multipart / form-data类型的请求中的文件:

  HttpURLConnection cxn =(HttpURLConnection)新的URL(uploadUrl).openConnection(); 
cxn.setRequestMethod(POST);
cxn.setChunkedStreamingMode(9999);
cxn.setRequestProperty(Content-Type,multipart / form-data; boundary = - );
cxn.setDoOutput(true);
cxn.connect();

开发服务器通过状态411:所需长度来回答我的请求。这是否意味着不支持分块传输模式,还是我错误地初始化了连接?生产服务器在这里的行为不同吗?这种行为是在生成上传url时指定最大上传大小的结果吗?



编辑:



我只是注释掉 cxn.setChunkedStreamingMode(9999); 这一行,但我宁愿不这样做,所以我不必缓冲数百MB在内存中发送请求之前...

解决方案

以下是我对上述问题的测试结果:


  1. 开发服务器不支持 支持上传的分块传输编码。

  2. 生产服务器不支持,如Stuart所示。 (phew)

  3. 我会重新报告指定上传大小限制的任何依赖性,但我怀疑它是否重要。

不幸的是,我必须编写两个版本的代码,一个用于在开发服务器上测试,另一个用于在生产服务器上运行,但这绝对是可接受的方案。

I'm having a really hard time finding documentation on a very basic question about AppEngine:

Does the BlobStore support Chunked Transfer Encoding for uploads?

I'm using an HttpURLConnection object in Java with setChunkedStreamingMode to upload a file in a multipart/form-data type request using the following code to set up the connection:

HttpURLConnection cxn = (HttpURLConnection) new URL(uploadUrl).openConnection();
cxn.setRequestMethod("POST");
cxn.setChunkedStreamingMode(9999);
cxn.setRequestProperty("Content-Type", "multipart/form-data; boundary=-");
cxn.setDoOutput(true);
cxn.connect();

The dev-server answers my request with Status 411: Length required. Does this mean that chunked transfer mode is not supported, or am I initializing the connection incorrectly? Does the production server act differently here? Is this behavior a consequence of specifying a max upload size when generating the upload url?

EDIT:

If I simply comment out the line cxn.setChunkedStreamingMode(9999);, everything works perfectly, but I'd rather not do this, so I don't have to buffer hundreds of MB in memory before sending the request...

解决方案

Here are the result of my tests regarding the questions above:

  1. The development server does not support chunked transfer encoding for uploads.
  2. The production server does support it, as indicated by Stuart. (phew)
  3. I'll report back on any dependence on specifying an upload size limit, but I doubt it matters.

It's unfortunate, that I have to write two versions of my code, one for testing on the dev server and one for running on the production server, but this is definitely an acceptable scenario.

这篇关于AppEngine BlobStore是否支持上传的块化传输编码(状态411:所需长度)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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