使用Python瓶服务器接收来自Android的POST请求的FileEntity

使用Python瓶服务器接收来自Android的POST请求的FileEntity,android,python,bottle,Android,Python,Bottle,在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-AethersNot

在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.file。它们都没有键和值

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

在搜索时,我读到了有关实体的信息:“请求可能会传输实体”,该实体具有实体头和实体值。因此,它可能类似于file content=e.get(entity header)。

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

在Battle中,
request.body
包含原始的、未经解析的请求正文。如果为空,则表示未向服务器发送任何数据。我会在客户端搜索错误。
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);