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