Revert "added content types for cached uploads. weird caching bug still not fixed"

This reverts commit c15a0c2161ab509f46c10d84d8003741a1e29b3e
This commit is contained in:
minish 2023-01-04 22:38:52 +00:00 committed by minish
parent a4ca431a82
commit fd8d5ffe9a
4 changed files with 2 additions and 37 deletions

20
Cargo.lock generated
View File

@ -107,7 +107,6 @@ dependencies = [
"bytes",
"hyper",
"memory-cache-rs",
"mime_guess",
"rand",
"tokio",
"tokio-stream",
@ -386,16 +385,6 @@ version = "0.3.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d"
[[package]]
name = "mime_guess"
version = "2.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef"
dependencies = [
"mime",
"unicase",
]
[[package]]
name = "mio"
version = "0.8.5"
@ -789,15 +778,6 @@ version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642"
[[package]]
name = "unicase"
version = "2.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6"
dependencies = [
"version_check",
]
[[package]]
name = "unicode-ident"
version = "1.0.5"

View File

@ -14,5 +14,4 @@ tokio-stream = "0.1"
tower = "0.4.13"
bytes = "1"
rand = "0.8.5"
mime_guess = "2.0.4"
memory-cache-rs = "0.2.0"

View File

@ -139,8 +139,6 @@ pub async fn new(
println!("[upl] caching upload!!");
cache.insert(name, data.freeze(), Some(Duration::from_secs(120)));
}
drop(cache);
});
Ok(url)

View File

@ -7,11 +7,10 @@ use std::{
use axum::{
body::StreamBody,
extract::{Path, State},
response::{IntoResponse, Response}, debug_handler, http::HeaderValue,
response::{IntoResponse, Response}, debug_handler,
};
use bytes::{buf::Reader, Bytes};
use hyper::StatusCode;
use mime_guess::{mime, Mime};
use tokio::fs::File;
use tokio_util::io::ReaderStream;
@ -77,18 +76,7 @@ pub async fn view(
let data = cache_item.unwrap().clone();
drop(cache);
let contentType = mime_guess::from_path(name).first().unwrap_or(mime::APPLICATION_OCTET_STREAM).to_string();
let mut res = data.into_response();
let mut headers = res.headers_mut();
headers.clear();
headers.insert("content-type", HeaderValue::from(contentType));
return res;
return data.into_response();
}
/* pub async fn view(