on 12-21-2012 5:33 AM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.