Upgrade to Actix V2, bump SQLX version, code cleanup, intergrate ratelimiter (#288)

* Upgrade to Actix V2, bump SQLX version, code cleanup, intergrate ratelimiter

* Add pack file path validation

* Fix compilation error caused by incorrect merge
This commit is contained in:
Geometrically
2022-02-05 23:08:30 -07:00
committed by GitHub
parent 6a89646e66
commit 6bf5dbabee
27 changed files with 1417 additions and 1649 deletions

View File

@@ -1,6 +1,6 @@
use crate::file_hosting::{DeleteFileData, FileHost, FileHostingError, UploadFileData};
use async_trait::async_trait;
use bytes::{Buf, Bytes};
use bytes::Bytes;
use s3::bucket::Bucket;
use s3::creds::Credentials;
use s3::region::Region;
@@ -42,14 +42,10 @@ impl FileHost for S3Host {
file_bytes: Bytes,
) -> Result<UploadFileData, FileHostingError> {
let content_sha1 = sha1::Sha1::from(&file_bytes).hexdigest();
let content_sha512 = format!("{:x}", sha2::Sha512::digest(file_bytes.bytes()));
let content_sha512 = format!("{:x}", sha2::Sha512::digest(&*file_bytes));
self.bucket
.put_object_with_content_type(
format!("/{}", file_name),
file_bytes.bytes(),
content_type,
)
.put_object_with_content_type(format!("/{}", file_name), &*file_bytes, content_type)
.await?;
Ok(UploadFileData {