File types (#506)

* File types

* Run prepare + fmt

* Switch to struct

* Update docker version
This commit is contained in:
Geometrically
2022-12-23 16:36:53 -07:00
committed by GitHub
parent 5f175141e1
commit fe256d6a62
15 changed files with 388 additions and 671 deletions

View File

@@ -1473,6 +1473,18 @@ pub async fn add_gallery_item(
let id: ProjectId = project_item.inner.id.into();
let url = format!("data/{}/images/{}.{}", id, hash, &*ext.ext);
let file_url = format!("{}/{}", cdn_url, url);
if project_item
.gallery_items
.iter()
.any(|x| x.image_url == file_url)
{
return Err(ApiError::InvalidInput(
"You may not upload duplicate gallery images!".to_string(),
));
}
file_host
.upload_file(content_type, &url, bytes.freeze())
.await?;
@@ -1494,7 +1506,7 @@ pub async fn add_gallery_item(
}
database::models::project_item::GalleryItem {
image_url: format!("{}/{}", cdn_url, url),
image_url: file_url,
featured: item.featured,
title: item.title,
description: item.description,