0

我正在开发一个网络服务器应用程序,用户可以从浏览器将文件上传到android设备。我相信apache commons文件上传可用于使用servlets在服务器端解析多部分表单请求。有什么办法可以在android服务器端完成。我只能消费请求正文。

                                -----------------------------4966737613931 Content-Disposition: form-data; name="datafile"; filename="log with spaces[ezees'.i]godknows.txt" Content-Type: text/plain 08-15 15:54:22.112: I/Process(650): Sending signal. PID: 650 SIG: 9 08-15 15:54:27.532: I/HTTPSERVICE(662): Creating and starting httpService 08-15 15:54:27.542: I/Notification(662): Notification Shown 08-15 16:08:19.332: I/HTTPSERVICE(662): Destroying httpService 08-15 16:08:19.352: I/Notification(662): Notification Destroyed 08-15 16:20:14.852: I/HTTPSERVICE(690): Creating and starting httpService 08-15 16:20:14.862: I/Notification(690): Notification Shown 08-15 16:20:28.102: D/dalvikvm(690): GC freed 2292 objects / 135976 bytes in 157ms 08-15 16:20:28.872: I/Resources(690): Loaded time zone names for en_US in 3090ms. 08-15 16:20:28.882: I/global(690): Default buffer size used in BufferedReader constructor. It would be better to be explicit if an 8k-char buffer is required. 08-15 16:20:35.302: I/System.out(690): Host: localhost:8080 08-15 16:20:35.382: I/System.out(690): Accept-Encoding: gzip 08-15 16:20:35.422: I/System.out(690): Referer: http://localhost:8080/ 08-15 16:20:35.422: I/System.out(690): Accept-Language: en-US 08-15 16:20:35.442: I/System.out(690): User-Agent: Mozilla/5.0 (Linux; U; Android 2.1-update1; en-us; sdk Build/ECLAIR) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17 08-15 16:20:35.472: I/System.out(690): Origin: http://localhost:8080 08-15 16:20:35.512: I/System.out(690): Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 08-15 16:20:35.533: I/System.out(690): Content-Type: application/x-www-form-urlencoded 08-15 16:20:35.562: I/System.out(690): Accept-Charset: utf-8, iso-8859-1, utf-16, *;q=0.7 08-15 16:20:35.599: I/System.out(690): Content-Length: 25 -----------------------------4966737613931--

这也是一个文本文件。使用 java 手动读取文件上传请求时涉及的解析内在函数是什么?我想从请求正文中获取文件名和文件数据。任何正确方向的想法或指针都是非常感谢。谢谢

4

0 回答 0