ashishdhiman2007
ashishdhiman2007

Reputation: 817

What is Java equivalent of $ curl --upload-file $uploadFileName $upload_url

I am trying to upload a zip file on amazon S3 bucket using android. But the specification I have for the upload is shown using

curl --upload-file $uploadFileName $upload_url command

I am at the moment using:

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();

in AsyncTask(). There is some progress shown instantly like 30-40% on progress bar but then

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

What is the reason for this error. Is there any other way to upload zip file on to server because using

curl --upload-file

it is working (according to server side people) and I want to implement this upload functionality using Android.

Upvotes: 0

Views: 866

Answers (1)

Murf
Murf

Reputation: 1719

After a quick Google I found some information about it. It means that the pipe to the server is broken; in other words: the server closes the connection. This can be due a too big file upload. Could you verify that the file is not too big for the upload or try some other (perhaps smaller) file?

Upvotes: 1

Related Questions