Does AppEngine BlobStore support Chunked Transfer

2019-07-02 23:36发布

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...

1条回答
▲ chillily
2楼-- · 2019-07-03 00:33

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.

查看更多
登录 后发表回答