2

在 Android 手机上,我使用 setEntity() 将 FileEntity 放入 POST 请求。

HttpPost post = new HttpPost(uri);
FileEntity reqEntity = new FileEntity(f, "application/x-gzip");
reqEntity.setContentType("binary/octet-stream");
reqEntity.setChunked(true);
post.addHeader("X-AethersNotebook-Custom", configuration.getCustomHeader());
post.setEntity(reqEntity);

使用瓶子时,试过这个,但它不起作用

f = request.body
gzipper = gzip.GzipFile( fileobj= f )
content = gzipper.read()

内容将是一个空字符串。所以我尝试查看 request.forms 和 request.files。它们都没有关键和价值。

request.files.keys()
request.forms.keys()

搜索时,我读到了实体:“一个请求可以传输实体”并且该实体具有实体标头和实体值。所以它可能类似于 file-content = e.get(entity-header)。

4

1 回答 1

1

使用该代码,手机使用分块编码发送文件。因为 py-bottle 不支持分块编码,所以这里的解决方案是重写 android 以将文件作为 POST 请求的主体发送。

于 2011-11-10T11:42:43.587 回答