Skip to Content

Extracting files from a zip archive posted from POSTMAN to HANA XS

Feb 26 at 12:44 PM


avatar image

Hello Community

I have tried posting a zip file from POSTMAN via form-data to a HANA XSJS service.

I am trying to access the zip using following code as mentioned in XSJS API reference i.e$.util.Zip.html-

var archive = $.request.body; 
var zip =new $.util.Zip(archive.asArrayBuffer());

However, archive i.e $.request.body comes as undefined.

Please let me know if this is the correct approach to post and extract zip file content.


capture.png (30.7 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Florian Pfeffer
Feb 27 at 06:47 AM

In case you transfer your zip file via multipart formdata, the content of the file is not part of the body property of the request. Each part of the multipart formdata request is part of then entities array of the request. Only in case you send the file as binary, the zip file content will be available in the body of the request.

Here is a quick and dirty example (no check for errors, invalid index access, ...) for your case, assuming that your zip file is the first part of your request:

var archive = $.request.entities[0].body;
var zip = new $.util.Zip(archive.asArrayBuffer());


Show 5 Share
10 |10000 characters needed characters left characters exceeded

Hi Florian

Thanks for the response. I have tried the below code -

var type = "";
var contents = "";
var i;
for (i = 0; i < $.request.entities.length; i++) {
if ($.request.entities[i].body) {
type = $.request.entities[i].contentType;
var zip = new $.util.Zip($.request.entities[i].body.asArrayBuffer());
contents =  zip["DocStore_SCN_Ques.txt"];
file.type = type; = zip;
file.contents = contents;
} catch (e) {
throw "Failed to upload file: EXCEPTION=" + e.message;
return JSON.stringify(file);

Postman response -


How do I read the text stored in a file present in zip file? I would like to store it as BLOB content in HANA Table.

Kindly help.


The way you are doing it is correct, as for each file a property is added to the "zip" object. So accessing it with the correct file name has to work. Of course your txt file needs to have some content to see it in your output. Have you checked that your file name is correct and that the file is not empty. You can also check the zip object in the debugger for further details.


Hi Florian

My txt file has content inside it and the file name is correct. Unfortunately contents are always empty. :(

Now, comes another question i.e Can I debug a XSJS which is fired using a POST request? I have tried this by placing a breakpoint in XSJS but it doesn't work.

Please share your views.


Hm, I have implemented an own example and it worked like assumed/described.

Regarding debugging, please check my answer here


Hi Florian

I have used a way of reading from array buffer(i.e file) and storing it.

Thanks for your inputs.