forked from neri/datatrash
fix upload without filename
This commit is contained in:
parent
16ba5f025e
commit
f9de6e5164
|
@ -416,7 +416,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "datatrash"
|
name = "datatrash"
|
||||||
version = "2.0.2"
|
version = "2.0.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"actix-files",
|
"actix-files",
|
||||||
"actix-governor",
|
"actix-governor",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "datatrash"
|
name = "datatrash"
|
||||||
version = "2.0.2"
|
version = "2.0.3"
|
||||||
authors = ["neri"]
|
authors = ["neri"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
|
|
|
@ -55,9 +55,9 @@ pub async fn upload(
|
||||||
"{} create new file {} (valid_till: {}, content_type: {}, delete_on_download: {})",
|
"{} create new file {} (valid_till: {}, content_type: {}, delete_on_download: {})",
|
||||||
req.connection_info().realip_remote_addr().unwrap_or("-"),
|
req.connection_info().realip_remote_addr().unwrap_or("-"),
|
||||||
file_id,
|
file_id,
|
||||||
|
upload_config.valid_till,
|
||||||
upload_config.content_type,
|
upload_config.content_type,
|
||||||
upload_config.delete_on_download,
|
upload_config.delete_on_download
|
||||||
upload_config.valid_till
|
|
||||||
);
|
);
|
||||||
|
|
||||||
expiry_watch_sender.send(()).await.unwrap();
|
expiry_watch_sender.send(()).await.unwrap();
|
||||||
|
@ -145,17 +145,20 @@ fn get_redirect_url(id: &str, name: Option<&str>) -> String {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn uploaded(
|
pub async fn uploaded(req: HttpRequest) -> Result<HttpResponse, Error> {
|
||||||
req: HttpRequest,
|
let id = req.match_info().query("id");
|
||||||
path: web::Path<(String, Option<String>)>,
|
let name = req
|
||||||
) -> Result<HttpResponse, Error> {
|
.match_info()
|
||||||
let (id, name) = path.into_inner();
|
.get("name")
|
||||||
|
.map(urlencoding::decode)
|
||||||
|
.transpose()
|
||||||
|
.map_err(|_| error::ErrorBadRequest("name is invalid utf-8"))?;
|
||||||
let upload_html = if name.is_some() {
|
let upload_html = if name.is_some() {
|
||||||
UPLOAD_SHORT_HTML
|
UPLOAD_SHORT_HTML
|
||||||
.replace("{link}", &get_file_url(&req, &id, name.as_deref()))
|
.replace("{link}", &get_file_url(&req, id, name.as_deref()))
|
||||||
.replace("{shortlink}", &get_file_url(&req, &id, None))
|
.replace("{shortlink}", &get_file_url(&req, id, None))
|
||||||
} else {
|
} else {
|
||||||
UPLOAD_HTML.replace("{link}", &get_file_url(&req, &id, name.as_deref()))
|
UPLOAD_HTML.replace("{link}", &get_file_url(&req, id, name.as_deref()))
|
||||||
};
|
};
|
||||||
Ok(HttpResponse::Ok()
|
Ok(HttpResponse::Ok()
|
||||||
.content_type("text/html")
|
.content_type("text/html")
|
||||||
|
|
Loading…
Reference in New Issue