NanoHttpd を使用して、ローカル ネットワークを介したファイル転送に成功しました。ただし、NanoHttpd Response でファイル名を送信できません。受信したファイルのデフォルト名は、localhost_8080 のようになります。を使用してレスポンスヘッダーにファイル名を添付しようとしましContent-disposition
たが、ファイル転送がすべて失敗しました。私は何を間違っていますか?これが私の実装です:
private class WebServer extends NanoHTTPD {
String MIME_TYPE;
File file;
public WebServer() {
super(PORT);
}
@Override
public Response serve(String uri, Method method,
Map<String, String> header, Map<String, String> parameters,
Map<String, String> files) {
try {
file=new File(fileToStream);
fis = new FileInputStream(file);
bis = new BufferedInputStream(fis);
MIME_TYPE= URLConnection.guessContentTypeFromName(file.getName());
} catch (IOException ioe) {
Log.w("Httpd", ioe.toString());
}
NanoHTTPD.Response res=new NanoHTTPD.Response(Status.OK, MIME_TYPE, bis);
res.addHeader("Content-Disposition: attachment; filename=", file.getName());
return res;
}
}
ご協力いただきありがとうございます!