#MultipartForm with vec<Bytes>

1 messages · Page 1 of 1 (latest)

gusty cobalt
#

Hi.

I'm reading the docs and it seems that I'm getting something wrong.

I don't want my upload to touch the disk directly.

I want to hold in memory, to do some work on the file.

And if I decide to save the file I will use a buffer to limit the amount of memory used.

struct UploadForm {
    file: Vec<actix_multipart::form::bytes::Bytes>,
}
async fn upload( MultipartForm(form): MultipartForm<UploadForm> ) -> impl Responder {
    // no body just for test
    HttpResponse::Ok()    
}

It responds with 400 status with "payload reached size limit" message.

gusty cobalt
#

Hi, thanks for the reply.

#

I was confused by the response.

After banging my head a little bit, the message it’s not about the file size, it’s about the memory memory_limit.

I was doing everything correctly, but I was getting tricked by the message.

I was hitting the memory size limit, not file size limit, but the message it’s the same for both cases.

Which leads me to my next question.

Is it possible to stream big files with actix?

To explain what I need:
I have one endpoint to upload big files, and I stream the file to a 1mb buffer and read to a file, this way I can upload a 10 GB file to the app running in a small container that will use low memory.

This container doesn't peak to 20mb when uploading a 10 GB file.

I’m struggling to do this with actix.

#

I keep getting the message "payload reached size limit" because it's trying to load the 10GB file to memory, and I can't find a way to stream 1mb at a time to the file.

void geyser
#

I think there's an example in the repo... but it doesn't sound like you're operating on the files, if thats the case then you'd be better off using a blob storage and signed urls

brazen pawn
#

yes but you need a more manual approach to get streaming working

gusty cobalt
brazen pawn
#

If you have any ideas how the stream version could work with struct typing I’d love to hear it