继续实现一部分文件下载
This commit is contained in:
parent
aef3a89af8
commit
70400f671c
13
src/serve.rs
13
src/serve.rs
@ -25,6 +25,7 @@ impl IntoResponse for MeasureRes {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 用于测速
|
||||||
/// ```ts
|
/// ```ts
|
||||||
/// import express from 'express'
|
/// import express from 'express'
|
||||||
///
|
///
|
||||||
@ -75,6 +76,16 @@ pub async fn res_donwload(
|
|||||||
) -> impl IntoResponse {
|
) -> impl IntoResponse {
|
||||||
let hash = hash.to_lowercase();
|
let hash = hash.to_lowercase();
|
||||||
let file_path = config.cache_dir.join(hash_to_filename(&hash));
|
let file_path = config.cache_dir.join(hash_to_filename(&hash));
|
||||||
|
let req_name = param.get("name");
|
||||||
|
let mut res = Response::builder().status(StatusCode::OK);
|
||||||
|
{
|
||||||
|
let mut header = res.headers_mut().unwrap();
|
||||||
|
header.insert("x-bmclapi-hash", hash.parse().unwrap());
|
||||||
|
if let Some(req_name) = req_name {
|
||||||
|
header.insert("Content-Disposition", req_name.parse().unwrap());
|
||||||
|
// Content-Type
|
||||||
|
header.insert("Content-Type", "application/octet-stream".parse().unwrap());
|
||||||
|
}
|
||||||
|
}
|
||||||
todo!();
|
todo!();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user