mirror of
https://github.com/Noratrieb/upload.files.noratrieb.dev.git
synced 2026-01-16 10:35:04 +01:00
Correctly handle special characters
This commit is contained in:
parent
0124fa5ba5
commit
f0b2d83d59
1 changed files with 6 additions and 3 deletions
|
|
@ -92,7 +92,7 @@ async fn upload(State(config): State<Config>, multipart: Multipart) -> Result<Re
|
||||||
config
|
config
|
||||||
.s3_client
|
.s3_client
|
||||||
.put_opts(
|
.put_opts(
|
||||||
&req.name.as_str().into(),
|
&req.name,
|
||||||
object_store::PutPayload::from_bytes(req.bytes),
|
object_store::PutPayload::from_bytes(req.bytes),
|
||||||
object_store::PutOptions {
|
object_store::PutOptions {
|
||||||
mode: object_store::PutMode::Create,
|
mode: object_store::PutMode::Create,
|
||||||
|
|
@ -127,7 +127,7 @@ async fn upload(State(config): State<Config>, multipart: Multipart) -> Result<Re
|
||||||
}
|
}
|
||||||
|
|
||||||
struct UploadRequest {
|
struct UploadRequest {
|
||||||
name: String,
|
name: object_store::path::Path,
|
||||||
bytes: Bytes,
|
bytes: Bytes,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -194,8 +194,11 @@ async fn parse_req(mut multipart: Multipart) -> Result<UploadRequest> {
|
||||||
|
|
||||||
name = format!("/{name}");
|
name = format!("/{name}");
|
||||||
|
|
||||||
|
let path =
|
||||||
|
object_store::path::Path::parse(&name).wrap_err_with(|| format!("invalid path: {name}"))?;
|
||||||
|
|
||||||
Ok(UploadRequest {
|
Ok(UploadRequest {
|
||||||
name,
|
name: path,
|
||||||
bytes: file.ok_or_eyre("missing file")?,
|
bytes: file.ok_or_eyre("missing file")?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue