什么是 Java 等价物 $ curl --upload-file $uploadFileName $upload_ur



我正在尝试使用 android 在 amazon S3 存储桶上上传 zip 文件。但是我对上传的规范是使用

curl --upload-file $uploadFileName $upload_url命令

我目前正在使用:

int TIMEOUT_MILLISEC = 300000;  // = 5 mints
HttpParams httpParams = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(httpParams, TIMEOUT_MILLISEC);
HttpConnectionParams.setSoTimeout(httpParams, TIMEOUT_MILLISEC);
HttpClient httpclient = new DefaultHttpClient(httpParams);
HttpPost httppost = new HttpPost(uploadURL);
entity.addPart("uploadedfile", new FileBody((sourceFile), "application/zip"));
httppost.setEntity(entity);
HttpResponse response = null;
response = httpclient.execute(httppost);
HttpEntity r_entity = response.getEntity();

在 AsyncTask(( 中。进度条上立即显示一些进度,例如 30-40%,但随后

javax.net.ssl.SSLException: Write error: ssl=0x7f6f071b80: I/O error during system call, Connection reset by peer

此错误的原因是什么。有没有其他方法可以将zip文件上传到服务器,因为使用

curl --upload-file

它正在工作(根据服务器端人员的说法(,我想使用 Android 实现此上传功能。

快速谷歌后,我找到了一些关于它的信息。这意味着通往服务器的管道已损坏;换句话说:服务器关闭连接。这可能是由于文件上传太大。您能否验证文件对于上传来说不是太大或尝试其他(也许更小(文件?

最新更新