send filename

This commit is contained in:
Brandon Thomas committed 2026-06-20 09:02:13 -04:00
1 parent e54fe12125
commit aa47795441
5 files changed
+25 -24

No files matched your search

@@ -1,12 +0,0 @@
{
"db_name": "MySQL",
"query": "\nUPDATE uploaded_videos\nSET\n maybe_width = ?,\n maybe_height = ?,\n maybe_resolution = ?,\n maybe_detected_model_family = ?,\n maybe_detected_model_type = ?,\n maybe_report = ?,\n maybe_updated_ip_address = ?,\n version = version + 1\nWHERE token = ?\nLIMIT 1\n ",
"describe": {
"columns": [],
"parameters": {
"Right": 8
},
"nullable": []
},
"hash": "62f08d5f32bdc35e6faf43e3d21affa2dcf1501cda831cb88524bf1571d08e2f"
}
@@ -1,12 +0,0 @@
{
"db_name": "MySQL",
"query": "\nINSERT INTO uploaded_videos\nSET\n token = ?,\n sha1_checksum = ?,\n filesize_bytes = ?,\n maybe_width = ?,\n maybe_height = ?,\n maybe_resolution = ?,\n maybe_detected_model_family = ?,\n maybe_detected_model_type = ?,\n maybe_report = ?,\n upload_ip_address = ?,\n created_at = NOW()\n ",
"describe": {
"columns": [],
"parameters": {
"Right": 10
},
"nullable": []
},
"hash": "64efd175fa4eb751be1125d55de93ed66a9fc6582e36cec4fc8225c350ec51e2"
}
@@ -12,6 +12,7 @@ where
{
pub sha1_checksum: &'e str,
pub filesize_bytes: u32,
pub maybe_filename: Option<&'e str>,
pub maybe_width: Option<u32>,
pub maybe_height: Option<u32>,
@@ -45,6 +46,7 @@ SET
token = ?,
sha1_checksum = ?,
filesize_bytes = ?,
maybe_filename = ?,
maybe_width = ?,
maybe_height = ?,
maybe_resolution = ?,
@@ -57,6 +59,7 @@ SET
token.as_str(),
args.sha1_checksum,
args.filesize_bytes,
args.maybe_filename,
args.maybe_width,
args.maybe_height,
args.maybe_resolution,
@@ -12,6 +12,8 @@ where
{
pub token: &'e UploadedVideoToken,
pub maybe_filename: Option<&'e str>,
pub maybe_width: Option<u32>,
pub maybe_height: Option<u32>,
pub maybe_resolution: Option<&'e str>,
@@ -41,6 +43,7 @@ where
r#"
UPDATE uploaded_videos
SET
maybe_filename = ?,
maybe_width = ?,
maybe_height = ?,
maybe_resolution = ?,
@@ -52,6 +55,7 @@ SET
WHERE token = ?
LIMIT 1
"#,
args.maybe_filename,
args.maybe_width,
args.maybe_height,
args.maybe_resolution,
@@ -10,6 +10,7 @@ use std::marker::PhantomData;
use std::sync::Arc;
use actix_multipart::form::tempfile::TempFile;
use actix_multipart::form::text::Text;
use actix_multipart::form::MultipartForm;
use actix_web::web::Json;
use actix_web::{web, HttpRequest};
@@ -47,6 +48,11 @@ pub struct VideoInfoUploadForm {
#[multipart(limit = "256 MiB")]
#[schema(value_type = Vec<u8>, format = Binary)]
file: TempFile,
/// Optional filename to record. Falls back to the uploaded file's own name.
#[multipart(limit = "2 KiB")]
#[schema(value_type = Option<String>, format = Binary)]
maybe_filename: Option<Text<String>>,
}
/// Detect a video's AI-generation provenance and persist the result.
@@ -90,6 +96,16 @@ pub async fn video_info_upload_handler(
let filesize_bytes = bytes.len().min(u32::MAX as usize) as u32;
let ip_address = get_request_ip(&http_request);
// Prefer an explicit `maybe_filename` field; otherwise use the uploaded file's
// own name. Trimmed; empty becomes absent.
let maybe_filename = form
.maybe_filename
.as_ref()
.map(|filename| filename.as_str().to_string())
.or_else(|| form.file.file_name.clone())
.map(|filename| filename.trim().to_string())
.filter(|filename| !filename.is_empty());
let sha1_checksum =
sha1_hash_bytes_as_crockford(&bytes).map_err(CommonWebError::from_error)?;
@@ -154,6 +170,7 @@ pub async fn video_info_upload_handler(
Some(existing) => {
update_uploaded_video(UpdateUploadedVideoArgs {
token: &existing.token,
maybe_filename: maybe_filename.as_deref(),
maybe_width,
maybe_height,
maybe_resolution: maybe_resolution.as_deref(),
@@ -171,6 +188,7 @@ pub async fn video_info_upload_handler(
insert_uploaded_video(InsertUploadedVideoArgs {
sha1_checksum: &sha1_checksum,
filesize_bytes,
maybe_filename: maybe_filename.as_deref(),
maybe_width,
maybe_height,
maybe_resolution: maybe_resolution.as_deref(),