diff --git a/api/src/endpoint/index.rs b/api/src/endpoint/index.rs index 67b0b03..1ef58f8 100644 --- a/api/src/endpoint/index.rs +++ b/api/src/endpoint/index.rs @@ -59,10 +59,10 @@ pub async fn show_file( config: &State, ) -> UploaderResult { let mut transaction = database.begin().await.map_err(|_| Error::DatabaseError)?; - let image = find_file_by_id(&mut transaction, &id.to_string()) + let file = find_file_by_id(&mut transaction, &id.to_string()) .await .map_err(|_| Error::FileNotFoundError)?; - let data = bucket.get(&image.bucket_id).await.unwrap(); + let data = bucket.get(&file.bucket_id).await.unwrap(); let file_type = &data.content_type.ok_or(Error::FileConvertError)?; let file_bytes = data .body diff --git a/api/src/endpoint/v1/error.rs b/api/src/endpoint/v1/error.rs index 4637804..046ff85 100644 --- a/api/src/endpoint/v1/error.rs +++ b/api/src/endpoint/v1/error.rs @@ -17,7 +17,7 @@ pub enum Error { #[error("Invalid auth key")] #[uploader(status_code = 403)] Unauthorized, - #[error("The file image is too large")] + #[error("The file is too large")] #[uploader(status_code = 403)] FileTooLargeError, #[error("The file does not exist")] diff --git a/api/src/endpoint/v1/file/delete.rs b/api/src/endpoint/v1/file/delete.rs index eefc8ff..34c8885 100644 --- a/api/src/endpoint/v1/file/delete.rs +++ b/api/src/endpoint/v1/file/delete.rs @@ -20,15 +20,15 @@ pub async fn delete(id: &str, database: PostgresDb, bucket: BucketGuard) -> Uplo } /// Deletes a file by its secret id, this prevents unauthorized third parties to -/// delete random image ids +/// delete random file ids async fn inner_delete(id: &str, database: PostgresDb, bucket: BucketGuard) -> UploaderResult<()> { let mut transaction = database.begin().await.map_err(|_| Error::DatabaseError)?; - let image = delete_file_by_secret(&mut transaction, &id.to_string()) + let file = delete_file_by_secret(&mut transaction, &id.to_string()) .await .map_err(|_| Error::FileNotFoundError)?; bucket - .delete(&image.bucket_id.as_str()) + .delete(&file.bucket_id.as_str()) .await .map_err(|_| Error::BucketDeleteError)?; diff --git a/api/src/endpoint/v1/file/upload.rs b/api/src/endpoint/v1/file/upload.rs index 6d5484a..c9994c7 100644 --- a/api/src/endpoint/v1/file/upload.rs +++ b/api/src/endpoint/v1/file/upload.rs @@ -79,7 +79,7 @@ pub async fn upload( } } - // As we use transactions, if the image upload fails the image will be dropped + // As we use transactions, if the file upload fails the file will be dropped save_file( &mut transaction, &id, @@ -118,7 +118,7 @@ pub async fn upload( // TODO: Make api url configurable Ok(UploadResponse::new( format!("{}/{}", config.public_url, &id), - format!("{}/api/v1/image/delete/{}", config.public_url, &secret), + format!("{}/api/v1/file/delete/{}", config.public_url, &secret), )) } diff --git a/api/src/main.rs b/api/src/main.rs index 89e8aa9..a119d37 100644 --- a/api/src/main.rs +++ b/api/src/main.rs @@ -11,7 +11,7 @@ pub mod s3; pub struct GlobalConfig { // Public server url public_url: String, - // Length of the file id used for "shwoing" the image + // Length of the file id used for "shwoing" the file file_id_length: usize, // Defines a Cache-Control header, time is in seconds cache_length: Option,