add: move upload server to buckets

This commit is contained in:
trisua 2025-08-21 00:30:29 -04:00
parent 8116307ba0
commit 75fe720f21
83 changed files with 351 additions and 458 deletions

View file

@ -146,11 +146,16 @@ pub async fn create_request(
for _ in 0..images.len() {
props.uploads.push(
match data
.create_upload(MediaUpload::new(MediaType::Webp, props.owner))
.2
.create_upload(MediaUpload::new(
MediaType::Webp,
props.owner,
"post_media".to_string(),
))
.await
{
Ok(u) => u.id,
Err(e) => return Json(e.into()),
Err(e) => return Json(Error::MiscError(e.to_string()).into()),
},
);
}
@ -164,22 +169,24 @@ pub async fn create_request(
let image = match images.get(i) {
Some(img) => img,
None => {
if let Err(e) = data.delete_upload(*upload_id).await {
return Json(e.into());
if let Err(e) = data.2.delete_upload(*upload_id).await {
return Json(Error::MiscError(e.to_string()).into());
}
continue;
}
};
let upload = match data.get_upload_by_id(*upload_id).await {
let upload = match data.2.get_upload_by_id(*upload_id).await {
Ok(u) => u,
Err(e) => return Json(e.into()),
Err(e) => return Json(Error::MiscError(e.to_string()).into()),
};
if let Err(e) =
save_webp_buffer(&upload.path(&data.0.0).to_string(), image.to_vec(), None)
{
if let Err(e) = save_webp_buffer(
&upload.path(&data.2.0.0.directory).to_string(),
image.to_vec(),
None,
) {
return Json(Error::MiscError(e.to_string()).into());
}
}