File Download from POST submission

hello,
I apologise for the dumb question but I can’t get my head around the documentation. I am trying to issue a POST submission to the server (all well and good) at which point the server performs some internal processing and then sends a (binary) file to the client. The POST submission through an ajax call is easy and the server side it straight forward.
The documentation mentions the ajax.response approach as below…
webix.ajax().response("blob").get("patch.zip", function(text, data){ //data - is a data blob });
but I don’t understand how this is actually implemented, or how to perform the POST and then get the browser to correctly deal with the “download headers”. Is there an example of how the client (webix) side of this would tie together that I can’t find? Any pointers would be very welcome.
Thanks for any and all assistance
-SrvrSide

https://docs.webix.com/api__html_download.html

webix.ajax().response("blob").get("patch.zip", function(text, data){
  //data - is a data blob
    webix.html.download(data, "patch.zip");
});

Thanks for the feedback Intregal, I was in the process of replying to you saying “yes I’ve read that documentation…” (which I have) when I saw the example and realised what i was missing. Thank you very much - like i said I apologise for the dumb question.
Thanks
-SrvrSide

I’m trying this, but every single time i get a corrupt file when trying to download an image.

    var blob = new Blob([dd], {
              type: "image/jpeg"
            });

            webix.html.download(blob, 'fuck.jpg')

I’ve tried adding a delay (webix.delay())… nothing.

Any help would be appreciated.

Is it possible to show a dialogue, where the user can select the dowload path, before downloading the file?

@GoKap

Hello,
is it possible to use the filename returned by the server?

I’m using this code:

    webix.ajax().response("blob").get("/api-v1/genforms", function(text, data) {
        webix.html.download(data, "file.docx");
    });

and my server returns the filename via response header:

    Cache-Control: public, max-age=0
    Content-Disposition: attachment; filename="dummy.docx"
    Content-Length: 24835
    Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document

Browser automatically picks the filename and saves the file. Any ideas to implement the same with webix.ajax().response?

Btw, many thanks for this great library.

Best regards
Dirk

@do13
ajax callback receives third argument as XMLHttpRequest.
try to get required header from this object.

webix.ajax().response("blob").get("/api-v1/genforms", function(text, data, xhr) {
  console.log(xhr.getResponseHeader("Content-Disposition"));
  webix.html.download(data, "file.docx");
});

Great, this fixes my problem. Thx for the help