On Thursday, 17 September 2020 at 16:32:55 UTC, WebFreak001 wrote:
On Thursday, 17 September 2020 at 16:00:33 UTC, wjoe wrote:
I found this [1] but unfortunately the post this refers to is
a dead link and the content, unfortunately, didn't tell me
anything that I didn't already find in the docs.
What I can get from the form is the form fields with content,
the field name for the file upload and the file name. But the
file name is useless to me because I need the file content.
Where is it stored ?
[1] https://aberba.com/2017/multiple-file-upload-in-vibe-d/
hi, you can access HTTPServerRequest.files which contains the
uploaded file.
Example in real code:
https://github.com/WebFreak001/ImageUploader/blob/master/source/app.d#L141-L159
Documentation: https://vibed.org/api/vibe.inet.webform/FilePart
Note: the file is only downloaded from the client / stored on
disk once you access the files or the form property, though
this isn't documented.
I don't believe the temp file behavior is customizable as it is
hardcoded here to write to a temporary file (which is called on
form parsing):
https://github.com/vibe-d/vibe.d/blob/ebebfa827f568cc9bced4bec2b66edc043a8adf7/inet/vibe/inet/webform.d#L311
However if you really wanted to (but I'd advise against it) you
could parse the form data from the HTTPServerRequest.bodyReader
yourself
Yeah I think what he wants is a way to write the file into an
in-memory buffer. This is especially necessary it some
environments where you can write to disk at all.
How that's done, even in node.js is to use a middleware for
parsing library to parse the headers in such way. I often use
multer (which is also based on busybody) to do that in nodejs.
Unfortunately I haven't used D to that extent to need such a
thing... I in never hit that problem.
I wonder if using a psuedo file handler will work for the
in-memory buffer thing.