digitalmars.D.learn - Vibe-D File Question
- Selim Ozel (10/10) Sep 11 2020 It seems like rejected-software forum is flooded with spam, so I
- Daniel Kozak (3/13) Sep 11 2020 https://vibed.org/api/vibe.http.server/HTTPServerResponse.writeBody
- Daniel Kozak (24/44) Sep 11 2020 import vibe.core.core;
- James Blachly (3/13) Sep 11 2020 Selim, note the Content-Disposition header in particular.
- Selim Ozel (4/17) Sep 12 2020 Thank you Daniel and James! The example works. It's exactly what
It seems like rejected-software forum is flooded with spam, so I decided to ask it here. Is there a way to generate a file -csv for example- on the back-end and serve it to the front-end as a file. Serve static file [1] function does this for files saved on the disk. I want to be able to generate a file during runtime and serve it to the client. Is this possible? Thanks, S [1] https://vibed.org/api/vibe.http.fileserver/serveStaticFile
Sep 11 2020
On Fri, Sep 11, 2020 at 1:10 PM Selim Ozel via Digitalmars-d-learn < digitalmars-d-learn puremagic.com> wrote:It seems like rejected-software forum is flooded with spam, so I decided to ask it here. Is there a way to generate a file -csv for example- on the back-end and serve it to the front-end as a file. Serve static file [1] function does this for files saved on the disk. I want to be able to generate a file during runtime and serve it to the client. Is this possible? Thanks, S [1] https://vibed.org/api/vibe.http.fileserver/serveStaticFilehttps://vibed.org/api/vibe.http.server/HTTPServerResponse.writeBody
Sep 11 2020
On Fri, Sep 11, 2020 at 1:15 PM Daniel Kozak <kozzi11 gmail.com> wrote:On Fri, Sep 11, 2020 at 1:10 PM Selim Ozel via Digitalmars-d-learn < digitalmars-d-learn puremagic.com> wrote:import vibe.core.core; import vibe.http.server; void main() { runWorkerTaskDist(&wrap); runApplication(); } void wrap() { auto settings = new HTTPServerSettings(":8080"); settings.options |= HTTPServerOption.reusePort; listenHTTP(settings, &fun); } void fun(HTTPServerRequest req, HTTPServerResponse res) nothrow { try { res.headers["Content-Disposition"] = "filename=\"muj.csv\""; res.writeBody("some;csv;data", "text/csv"); } catch (Exception e) {} }It seems like rejected-software forum is flooded with spam, so I decided to ask it here. Is there a way to generate a file -csv for example- on the back-end and serve it to the front-end as a file. Serve static file [1] function does this for files saved on the disk. I want to be able to generate a file during runtime and serve it to the client. Is this possible? Thanks, S [1] https://vibed.org/api/vibe.http.fileserver/serveStaticFilehttps://vibed.org/api/vibe.http.server/HTTPServerResponse.writeBody
Sep 11 2020
On 9/11/20 7:28 AM, Daniel Kozak wrote:void fun(HTTPServerRequest req, HTTPServerResponse res) nothrow { try { res.headers["Content-Disposition"] = "filename=\"muj.csv\""; res.writeBody("some;csv;data", "text/csv"); } catch (Exception e) {} }Selim, note the Content-Disposition header in particular. https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition
Sep 11 2020
On Friday, 11 September 2020 at 13:03:16 UTC, James Blachly wrote:On 9/11/20 7:28 AM, Daniel Kozak wrote:Thank you Daniel and James! The example works. It's exactly what I was asking for. I got the core idea with the Content Disposition article.void fun(HTTPServerRequest req, HTTPServerResponse res) nothrow { try { res.headers["Content-Disposition"] = "filename=\"muj.csv\""; res.writeBody("some;csv;data", "text/csv"); } catch (Exception e) {} }Selim, note the Content-Disposition header in particular. https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition
Sep 12 2020