cancel
Showing results for 
Search instead for 
Did you mean: 

Post the Zipfile/byte array using SUP Odata sdk-Android native

Former Member
0 Kudos

Hi,

I have tried posting the data(String) using the SUP Odata sdk to SAP via netweaver gateway from andriod device and its successful.

Now how can i post the zipfile/byet array of images to server using sup Odata sdk Libs.

For posting zipfile/byte array

1) What could be the structure of the  xml

2) Will sup Odata sdk lib supports posting zipfile? if not support posting zipfile which can be optimize way to post multiple image to server along with some data(String/text) appended to it? And if support posting zipfile what all could be the possible syntax and libs that can be used to post.

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

rohith_deraje
Advisor
Advisor
0 Kudos

Hi Yogesh,
Yes. oData SDK support posting of binary data (image/attachments) .Here is the sample header and request.
// Header
HashMap<String,
String> headers = new HashMap<String, String>();
headers.put("Content-Type", "image/jpg");
headers.put("X-Requested-With", "XMLHttpRequest");

//Request
ISDMRequest req = new SDMBaseRequest();
req.setRequestMethod(ISDMRequest.REQUEST_METHOD_PUT);
req.setHeaders(headers);
req.setRequestUrl(url);
req.setListener(listener);
byte[] data = null;
try {
String path =
Environment.getExternalStorageDirectory().getAbsolutePath();
String FilePath = "/data/app/image/Upload.bmp";
data = readFile(FilePath);
} catch (Exception e) {
// TODO: handle exception
}
req.setData(data);


Please write your implementation for "readFile(Filepath)" to read file from device memory.

Rest of the code is same for post of string data. Since you have already done a successful POST of string data. I am not sharing the code.

Hope this answers your query.

Regards

Rohith

Former Member
0 Kudos

Thanks for the quick response Rohith,Will try this , Is there any size constrain to transfer the image files

rohith_deraje
Advisor
Advisor
0 Kudos

Hi Yogesh,

There is no size limit imposed by SUP or SDK. However  file size more than 5MB may take more to read and upload from a mobile device. SO try to keep the attachment size to minimum for better performance of the app.

Please close this thread if your query is answered.

Regards

Rohith

Answers (0)