■サーバ
次をそのまま使わせてもらいました。
nginx 1.6.2 + lua-nginx-moduleで簡易ファイルアップローダー
http://symfoware.blog68.fc2.com/blog-entry-1562.html
次のhtmlで確認しました。
<html xmlns="http://www.w3.org/1999/xhtml"> <head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> </head> <body> <form action="/upload" method="POST" enctype="multipart/form-data"> <input type="file" name="upload1" /><br /> <input type="file" name="upload2" /><br /> <input type="submit" value="Upload Files" /> </form> </body> </html>
■クライアント (Android)
次のUpload data to the server using MultipartRequestを参考に、
ANDROID HTTP CLIENT:GET,POST,DOWNLOA,UPLOAD MULTIPART REQUEST
http://www.survivingwithandroid.com/2013/05/android-http-downlod-upload-multipart.html
multipartだけど全体のfilenameをつけるために
メソッドconnectForMultipart()に追加、
public void connectForMultipart(String filename) throws Exception {
…
con.setRequestProperty(“filename”, filename);
…
}
後はメソッドdoInBackground()を少しいじっただけ、
とりあえず疎通だけできました!
セキュア関係はまだなので、そこを仕上げてからまとめ直します。