vibe.d: How to get the conent of a file upload ?

aberba karabutaworld at
Thu Sep 17 20:38:47 UTC 2020

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]
> hi, you can access HTTPServerRequest.files which contains the 
> uploaded file.
> Example in real code: 
> Documentation:
> 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): 
> 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.

More information about the Digitalmars-d-learn mailing list