Can the client send a file? #2651
-
Something like: #[tokio::test]
async fn test_uploads_workbook_and_gets_topics() {
let client = Client::tracked(app()).await.unwrap()
let mut file = File::open("tests/fixtures/test.xlsx").unwrap();
let actual = client.post("/upload-workbook")
.body(file) // <---- The trait bound `std::fs::File: std::convert::AsRef<[u8]>` is not satisfied
.dispatch()
.await;
assert_eq!(actual.status(), rocket::http::Status::Created);
}
|
Beta Was this translation helpful? Give feedback.
Answered by
mathew-horner
Nov 24, 2023
Replies: 1 comment
-
The |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
SergioBenitez
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The
File
struct doesn't actually have the file contents. If you want to get the contents of the file, you can use one of thestd::io::Read
(link) methods (i.e.read_to_end
). Then you can send that data in your request.