mirror of
https://gitlab.com/famedly/conduit.git
synced 2025-08-06 17:40:59 +00:00
feat(service/media): add S3 support
This commit is contained in:
parent
30d578a81a
commit
6541402609
5 changed files with 143 additions and 3 deletions
|
@ -242,6 +242,32 @@ impl From<IncompleteConfig> for Config {
|
|||
}),
|
||||
directory_structure,
|
||||
},
|
||||
IncompleteMediaBackendConfig::S3 {
|
||||
endpoint,
|
||||
bucket,
|
||||
region,
|
||||
key,
|
||||
secret,
|
||||
duration,
|
||||
bucket_use_path,
|
||||
} => {
|
||||
let path_style = if bucket_use_path {
|
||||
rusty_s3::UrlStyle::Path
|
||||
} else {
|
||||
rusty_s3::UrlStyle::VirtualHost
|
||||
};
|
||||
|
||||
let bucket = rusty_s3::Bucket::new(endpoint, path_style, bucket, region)
|
||||
.expect("Invalid S3 config");
|
||||
|
||||
let credentials = rusty_s3::Credentials::new(key, secret);
|
||||
|
||||
MediaBackendConfig::S3 {
|
||||
bucket: bucket,
|
||||
credentials: credentials,
|
||||
duration: Duration::from_secs(duration),
|
||||
}
|
||||
}
|
||||
},
|
||||
retention: media.retention.into(),
|
||||
};
|
||||
|
@ -481,6 +507,17 @@ pub enum IncompleteMediaBackendConfig {
|
|||
#[serde(default)]
|
||||
directory_structure: DirectoryStructure,
|
||||
},
|
||||
S3 {
|
||||
endpoint: Url,
|
||||
bucket: String,
|
||||
region: String,
|
||||
key: String,
|
||||
secret: String,
|
||||
#[serde(default = "default_s3_duration")]
|
||||
duration: u64,
|
||||
#[serde(default = "false_fn")]
|
||||
bucket_use_path: bool,
|
||||
},
|
||||
}
|
||||
|
||||
impl Default for IncompleteMediaBackendConfig {
|
||||
|
@ -498,6 +535,11 @@ pub enum MediaBackendConfig {
|
|||
path: String,
|
||||
directory_structure: DirectoryStructure,
|
||||
},
|
||||
S3 {
|
||||
bucket: rusty_s3::Bucket,
|
||||
credentials: rusty_s3::Credentials,
|
||||
duration: Duration,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
|
@ -727,3 +769,7 @@ fn default_openid_token_ttl() -> u64 {
|
|||
pub fn default_default_room_version() -> RoomVersionId {
|
||||
RoomVersionId::V10
|
||||
}
|
||||
|
||||
fn default_s3_duration() -> u64 {
|
||||
30
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue