6

i have application that picks the file from a dedicated path on my device and sends it to server.

I m using ksoap2 lib to call .NET webservice to send my file to server. i am using Base 64 encoding.

I can send file with max size of 1MB without encryption and 850Kb with encryption. Encyrption algorithm i am using is 3DES.

If i try to send files larger than above size i get following error: Caused by: java.lang.OutOfMemoryError at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:121)

My Test environment: Android emulator with API Level 8, Android 2.2 and SDCard memory 512 MB

Is it that i am missing out something? Can using BLOB help me in this scenario

Is there any way to send larger file? i have heard of sending data chunks but have no idea on that . any link or sample code will really help.

to get file data using following code: here url = where file is stored

public byte[] getFileData( String vURL){ instream = new FileInputStream(vURL); size = (int) vURL.length();
fileContent = new byte[size]; instream.read(fileContent); }

Encode the data using following code:

byte[] res = Utilities.getFileData(file);
String mdata = android.util.Base64.encodeToString(res,                                android.util.Base64.DEFAULT);

calling server side web service and sending data to server

SoapObject request = new SoapObject(nameSpace, methodName);

if (fileData != null && !fileData.equals("")) {
      request.addProperty("vBLOBData", fileData);
}
   SoapSerializationEnvelope envelope = getEnvelope(request);
   HttpTransportSE ht = new HttpTransportSE(url); // ,3000
   ht.debug = true;
   ht.call(soapAction, envelope);
  response = (envelope.getResponse()).toString();

Not able to send filedata more than 1 MB.

Thanks in advance

  • Please post your code. Any answer to this question is just speculation unless we can actually see some code. – Deepak Bala Apr 06 '13 at 07:02
  • 1
    Please Specify how much larger the files you are trying to send here, since if those file are larger than 4 mb then the problem is not in your android part its all in your web service part and you need to configure your web.Config file by setting the following attributes . – Husam A. Al-ahmadi Apr 07 '13 at 22:43

4 Answers4

1

I don't know what you are trying to achieve, but why you don't divide your file into parts and send each part individually into a loop or into an android background service using a timer that sends a part every x seconds.

Yasmine GreenApple
  • 438
  • 1
  • 5
  • 15
0

Try to set your buffer to 1024 before sending it , its about the limit of your buffer size and your ram

Mohamed
  • 761
  • 9
  • 19
0

Use GZip Zipping algorithm to zip large file from mobile side; use same unzipping from server.

Also use MultipartEntity can help to upload large file content.

R World
  • 766
  • 9
  • 26
0

If compression doesn't help - as mentioned in previous post - you will probably have to segment the message yourself.

Segmentation

Community
  • 1
  • 1
adelpreore
  • 61
  • 1
  • 5