Android側からPHPサーバーにファイル(画像、ビデオ、オーディオ)をアップロードしています。小さなファイルに適しています。しかし、大きなファイルの場合、ファイルのアップロードなどの予期しない結果が発生しますが、Android 側ではタイムアウト例外が発生します。ファイルアップロードのすべてのシナリオにどのように取り組むか、私を助けてください。HttpMultipart エンティティを使用する方法と、異なるサイズのファイルに対して相対的なタイムアウトを設定する方法。私のコードは次のとおりです。
File myFile = new File(filePath);
RequestParams params = new RequestParams();
try {
params.put("uploaded_file", myFile);
} catch (FileNotFoundException e) {
}
URL=getResources().getString(com.newing.R.string.server_adderess)+URL+fileType+"&lessonID="+LessonID;
client.post(URL, params, new AsyncHttpResponseHandler() {
@Override
public void onSuccess(String response) {
Log.w("async", "success!!!!");
UtilityFunctions.showNotification(getApplicationContext(),
"File uploading completed.");
stopSelf();
}
@Override
public void onFailure(Throwable error) {
Log.w("async", "failure!!!!");
UtilityFunctions.showNotification(getApplicationContext(),
"File couldn't upload. Please try later.");
stopSelf();
}
});