[Seaside] Return document attachment from AJAX callback

Esteban A. Maringolo emaringolo at gmail.com
Thu Sep 20 18:15:27 UTC 2018


Is it possible to return a document attachment as a response of an ajax
call?

I'm currently returning a file as part of a regular action callback
associated with an anchor, but as most of the app is AJAX driven, it
would be convenient to not only return such document, but to do return
the document and/or a script to keep the UI in sync.

I'm currently returning the document by doing the following as part of
the callback:

downloadFile
self requestContext respond: [:response |
   response
     doNotCache;
     attachmentWithFileName: ...;
     contentType: ...,
     binary;
     nextPutAll: byteArray;
     respond
]

And I'd like to do something like.

html anchor
  jsUrl;
  onClick: (html jQuery ajax
              callback: [self downloadFile];
              script: [:s | ... ]);
  with: 'Download file'.

Regards,

-- 
Esteban A. Maringolo


More information about the seaside mailing list