You've already forked AstralRinth
forked from didirus/AstralRinth
R2 impl (#466)
* Add Cloudflare R2 impl * Bump actix version * Fix sec issues
This commit is contained in:
@@ -21,7 +21,7 @@ impl FileHost for MockHost {
|
||||
file_bytes: Bytes,
|
||||
) -> Result<UploadFileData, FileHostingError> {
|
||||
let path =
|
||||
std::path::Path::new(&dotenv::var("MOCK_FILE_PATH").unwrap())
|
||||
std::path::Path::new(&dotenvy::var("MOCK_FILE_PATH").unwrap())
|
||||
.join(file_name.replace("../", ""));
|
||||
std::fs::create_dir_all(
|
||||
path.parent().ok_or(FileHostingError::InvalidFilename)?,
|
||||
@@ -49,7 +49,7 @@ impl FileHost for MockHost {
|
||||
file_name: &str,
|
||||
) -> Result<DeleteFileData, FileHostingError> {
|
||||
let path =
|
||||
std::path::Path::new(&dotenv::var("MOCK_FILE_PATH").unwrap())
|
||||
std::path::Path::new(&dotenvy::var("MOCK_FILE_PATH").unwrap())
|
||||
.join(file_name.replace("../", ""));
|
||||
std::fs::remove_file(path)?;
|
||||
|
||||
|
||||
@@ -23,9 +23,15 @@ impl S3Host {
|
||||
) -> Result<S3Host, FileHostingError> {
|
||||
let mut bucket = Bucket::new(
|
||||
bucket_name,
|
||||
Region::Custom {
|
||||
region: bucket_region.to_string(),
|
||||
endpoint: url.to_string(),
|
||||
if bucket_region == "r2" {
|
||||
Region::R2 {
|
||||
account_id: url.to_string(),
|
||||
}
|
||||
} else {
|
||||
Region::Custom {
|
||||
region: bucket_region.to_string(),
|
||||
endpoint: url.to_string(),
|
||||
}
|
||||
},
|
||||
Credentials::new(
|
||||
Some(access_token),
|
||||
|
||||
Reference in New Issue
Block a user