made content_type optional

This commit is contained in:
Paul Zinselmeyer 2023-04-20 14:45:23 +02:00
parent 1ff78e414f
commit 255172d841
Signed by: pfzetto
GPG key ID: 4EEF46A5B276E648

View file

@ -135,7 +135,7 @@ async fn post_item(
Path(id): Path<String>, Path(id): Path<String>,
Query(params): Query<PostQuery>, Query(params): Query<PostQuery>,
State(app_state): State<AppState>, State(app_state): State<AppState>,
TypedHeader(content_type): TypedHeader<ContentType>, content_type: Option<TypedHeader<ContentType>>,
mut stream: BodyStream, mut stream: BodyStream,
) -> HandlerResult<impl IntoResponse> { ) -> HandlerResult<impl IntoResponse> {
let id = sanitize_id(id); let id = sanitize_id(id);
@ -171,7 +171,7 @@ async fn post_item(
data_file.write_all(&buf).await.unwrap(); data_file.write_all(&buf).await.unwrap();
} }
metadata.mimetype = Some(content_type.to_string()); metadata.mimetype = content_type.map(|x| x.0.to_string());
metadata.ttl = Some(expires_at); metadata.ttl = Some(expires_at);
metadata.to_file(&app_state.path, &id).await.unwrap(); metadata.to_file(&app_state.path, &id).await.unwrap();