Skip to Content
G B

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

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 https://help.sap.com/doc/3de842783af24336b6305a3c0223a369/2.0.00/en-US/$.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

capture.png (30.7 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

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

    Regards,
    Florian

    Add comment
    10|10000 characters needed characters exceeded