Closed dbrgn closed 3 years ago
Hey @dbrgn , there is nothing to do with async-std or tokio for the core features provided by multer. You have provided a wrong argument to the Multipart ::new()
method as described in the compiler error message.
The Multipart::new()
accepts a stream of Bytes as described here.
First convert the body.bytes()
to a stream of Bytes as below:
use bytes::Bytes;
let data: &[u8] = body.bytes();
// Convert your data to a stream of Bytes.
let stream = futures::stream::once(async move { Result::<Bytes, Infallible>::Ok(Bytes::from(data)) });
let multipart = multer::Multipart::new(stream, boundary);
Ah, perfect, thanks @rousan!
I tried to use multer in an async-std application.
This fails to compile because
Multipart::new
wants a stream ofBytes
, not a stream ofu8
.I cannot use
from_reader
either since that's a Tokio thing.What would be the appropriate way to use multer with async-std? (If I can get it to work, I can also contribute an example.)