Is there a way too -> Set form data & upload bytes at same time? #636
Unanswered
andrew-caines
asked this question in
Q&A
Replies: 2 comments 4 replies
-
I'm not sure I fully understand the API but it sounds like it wants a
multipart request, where one part contains the JSON attributes and the
second part contains the file contents. Ureq doesn't offer that natively,
but maybe the multipart crate will help?
https://docs.rs/multipart/latest/multipart/
Also I'll note that in your example you are just sending the string
"file.mp3". You'll need to actually read the contents of the file from
disl, then properly encode those bytes amd send them as part of the request.
|
Beta Was this translation helpful? Give feedback.
0 replies
-
Why cant we send a file manually?
why is this not possible? Edit: I've since asked on the rust discord for alternatives where this is possible and learned that the However this only changes my question to: Why cant we send arbitrary data to and field we like? Some endpoints expect some data in such a field |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I am looking to upload a file to a 3rd party API that requires some form-data be included with the files (bytes).
For example, this is a working version of the requirements inside POSTMAN.
I have tried using .send_bytes and it kinda works in the sense that the API will throw and error saying it got the file, but lacked its name and parent folder id.
This is what I am trying inside rust:
It complains that my file_to_upload is a Vec of bytes and not a string. Is there a way to mix .send_form & send_bytes, I honestly tried finding it in the Reference but I couldn't.
Please advise, how would one do this? (I honestly assume this is a common occurrence/requirement)
Thank you,
Andrew
Beta Was this translation helpful? Give feedback.
All reactions