我正在尝试使用 NanoHttpd 库通过表单中的 POST 请求将文件上传到我的 Android 服务器。我确实在服务器端收到了 POST 请求。我的问题是如何从 POST 请求中检索文件,以便我可以将其保存在设备内存中的某个位置。
表格 :
<form action='?' method='post' enctype='multipart/form-data'>
<input type='file' name='file' />`enter code here`
<input type='submit'name='submit' value='Upload'/>
</form>
服务方法:
@Override
public Response serve (IHTTPSession session) {
Method method = session.getMethod();
String uri = session.getUri();
if (Method.POST.equals(method)) {
//get file from POST and save it in the device memory
}
...
}