[Geoserver-users] Force download of WFS POST requests

Hi List,

I am aware of GeoServer supporting the content-disposition=attachment query parameters to force file download within the browser. This works fine.

My case however is to try this from within OpenLayers using OpenLayers-generated WFS requests. These WFS POST requests use Ajax XMLHTTPRequest. Although content-disposition headers can be passed and are rewarded by GeoServer, as per the design of Ajax, a download is never triggered.

Question is if there is another way, maybe with non-standard requests to GeoServer via for example a HTTP form submit (sending WFS POST body as Content-Type:application/x-www-form-urlencoded)? I will first try if this can be done from GeoServer directly before resorting into proxy-based solutions.

Thanks for any suggestions,

--Just van den Broecke
www.justobjects.nl

Hi List,

In the meantime I figured something out that works, so for the archive I'll share it here:

To trigger a WFS download (i.e. a 'Save file...' popup) and remain within the webpage without opening a new browser window can be done as follows within JavaScript (Heron MC/GeoExt in my case):

- construct a regular WFS URL (GET) with Filter encoded as parameter
- add the content-disposition=attachment etc params
- create a hidden iframe and assign the above WFS URL to the iframe 'src'

And voila: we have a WFS download to a file within the app!

best,

--Just

Just van den Broecke
www.justobjects.nl

On 14-05-13 19:56, Just van den Broecke wrote:

Hi List,

I am aware of GeoServer supporting the content-disposition=attachment
query parameters to force file download within the browser. This works fine.

My case however is to try this from within OpenLayers using
OpenLayers-generated WFS requests. These WFS POST requests use Ajax
XMLHTTPRequest. Although content-disposition headers can be passed and
are rewarded by GeoServer, as per the design of Ajax, a download is
never triggered.

Question is if there is another way, maybe with non-standard requests to
GeoServer via for example a HTTP form submit (sending WFS POST body as
Content-Type:application/x-www-form-urlencoded)? I will first try if
this can be done from GeoServer directly before resorting into
proxy-based solutions.

Thanks for any suggestions,

--Just van den Broecke
www.justobjects.nl

------------------------------------------------------------------------------
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

On Fri, May 17, 2013 at 12:12 PM, Just van den Broecke
<just@anonymised.com>wrote:

Hi List,

In the meantime I figured something out that works, so for the archive
I'll share it here:

To trigger a WFS download (i.e. a 'Save file...' popup) and remain
within the webpage without opening a new browser window can be done as
follows within JavaScript (Heron MC/GeoExt in my case):

- construct a regular WFS URL (GET) with Filter encoded as parameter
- add the content-disposition=attachment etc params
- create a hidden iframe and assign the above WFS URL to the iframe 'src'

And voila: we have a WFS download to a file within the app!

Nice, thanks for sharing

Cheers
Andrea

--

GeoServer training in Milan, 6th & 7th June 2013! Visit
http://geoserver.geo-solutions.it for more information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

-------------------------------------------------------