aws: Add system-defined metadata options to both sinks

Add to awss3sink and awss3putobjectsink elements the following
paramerters which are set on the uploaded S3 objects:

* cache-control;
* content-encoding; and
* content-language

Bugfix: Set the content-type and content-disposition values in the S3
putobject call. Previously the params were defined on the element but
unused.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1585>
This commit is contained in:
Liam 2024-05-24 11:11:19 +01:00 committed by Arun Raghavan
parent 4f74cb7958
commit b4fd6cf362
3 changed files with 160 additions and 0 deletions

View file

@ -237,6 +237,18 @@
"type": "gchararray",
"writable": true
},
"cache-control": {
"blurb": "Cache-Control header to set for uploaded object",
"conditionally-available": false,
"construct": false,
"construct-only": false,
"controllable": false,
"default": "NULL",
"mutable": "null",
"readable": true,
"type": "gchararray",
"writable": true
},
"content-disposition": {
"blurb": "Content-Disposition header to set for uploaded object",
"conditionally-available": false,
@ -249,6 +261,30 @@
"type": "gchararray",
"writable": true
},
"content-encoding": {
"blurb": "Content-Encoding header to set for uploaded object",
"conditionally-available": false,
"construct": false,
"construct-only": false,
"controllable": false,
"default": "NULL",
"mutable": "null",
"readable": true,
"type": "gchararray",
"writable": true
},
"content-language": {
"blurb": "Content-Language header to set for uploaded object",
"conditionally-available": false,
"construct": false,
"construct-only": false,
"controllable": false,
"default": "NULL",
"mutable": "null",
"readable": true,
"type": "gchararray",
"writable": true
},
"content-type": {
"blurb": "Content-Type header to set for uploaded object",
"conditionally-available": false,
@ -489,6 +525,18 @@
"type": "gchararray",
"writable": true
},
"cache-control": {
"blurb": "Cache-Control header to set for uploaded object",
"conditionally-available": false,
"construct": false,
"construct-only": false,
"controllable": false,
"default": "NULL",
"mutable": "null",
"readable": true,
"type": "gchararray",
"writable": true
},
"complete-upload-request-timeout": {
"blurb": "Timeout for the complete multipart upload request (in ms, set to -1 for infinity) (Deprecated. Use request-timeout.)",
"conditionally-available": false,
@ -529,6 +577,30 @@
"type": "gchararray",
"writable": true
},
"content-encoding": {
"blurb": "Content-Encoding header to set for uploaded object",
"conditionally-available": false,
"construct": false,
"construct-only": false,
"controllable": false,
"default": "NULL",
"mutable": "null",
"readable": true,
"type": "gchararray",
"writable": true
},
"content-language": {
"blurb": "Content-Language header to set for uploaded object",
"conditionally-available": false,
"construct": false,
"construct-only": false,
"controllable": false,
"default": "NULL",
"mutable": "null",
"readable": true,
"type": "gchararray",
"writable": true
},
"content-type": {
"blurb": "Content-Type header to set for uploaded object",
"conditionally-available": false,

View file

@ -104,8 +104,11 @@ struct Settings {
region: Region,
bucket: Option<String>,
key: Option<String>,
cache_control: Option<String>,
content_type: Option<String>,
content_disposition: Option<String>,
content_encoding: Option<String>,
content_language: Option<String>,
buffer_size: u64,
access_key: Option<String>,
secret_access_key: Option<String>,
@ -159,8 +162,11 @@ impl Default for Settings {
region: Region::new("us-west-2"),
bucket: None,
key: None,
cache_control: None,
content_type: None,
content_disposition: None,
content_encoding: None,
content_language: None,
access_key: None,
secret_access_key: None,
session_token: None,
@ -358,16 +364,22 @@ impl S3Sink {
) -> CreateMultipartUploadFluentBuilder {
let bucket = Some(url.bucket.clone());
let key = Some(url.object.clone());
let cache_control = settings.cache_control.clone();
let content_type = settings.content_type.clone();
let content_disposition = settings.content_disposition.clone();
let content_encoding = settings.content_encoding.clone();
let content_language = settings.content_language.clone();
let metadata = settings.to_metadata(self);
client
.create_multipart_upload()
.set_bucket(bucket)
.set_key(key)
.set_cache_control(cache_control)
.set_content_type(content_type)
.set_content_disposition(content_disposition)
.set_content_encoding(content_encoding)
.set_content_language(content_language)
.set_metadata(metadata)
}
@ -771,6 +783,10 @@ impl ObjectImpl for S3Sink {
.nick("S3 endpoint URI")
.blurb("The S3 endpoint URI to use")
.build(),
glib::ParamSpecString::builder("cache-control")
.nick("cache-control")
.blurb("Cache-Control header to set for uploaded object")
.build(),
glib::ParamSpecString::builder("content-type")
.nick("content-type")
.blurb("Content-Type header to set for uploaded object")
@ -779,6 +795,14 @@ impl ObjectImpl for S3Sink {
.nick("content-disposition")
.blurb("Content-Disposition header to set for uploaded object")
.build(),
glib::ParamSpecString::builder("content-encoding")
.nick("content-encoding")
.blurb("Content-Encoding header to set for uploaded object")
.build(),
glib::ParamSpecString::builder("content-language")
.nick("content-language")
.blurb("Content-Language header to set for uploaded object")
.build(),
glib::ParamSpecBoolean::builder("force-path-style")
.nick("Force path style")
.blurb("Force client to use path-style addressing for buckets")
@ -887,6 +911,11 @@ impl ObjectImpl for S3Sink {
let _ = self.set_uri(Some(&settings.to_uri()));
}
}
"cache-control" => {
settings.cache_control = value
.get::<Option<String>>()
.expect("type checked upstream");
}
"content-type" => {
settings.content_type = value
.get::<Option<String>>()
@ -897,6 +926,16 @@ impl ObjectImpl for S3Sink {
.get::<Option<String>>()
.expect("type checked upstream");
}
"content-encoding" => {
settings.content_encoding = value
.get::<Option<String>>()
.expect("type checked upstream");
}
"content-language" => {
settings.content_language = value
.get::<Option<String>>()
.expect("type checked upstream");
}
"force-path-style" => {
settings.force_path_style = value.get::<bool>().expect("type checked upstream");
}
@ -939,8 +978,11 @@ impl ObjectImpl for S3Sink {
(settings.retry_attempts as i64 * request_timeout).to_value()
}
"endpoint-uri" => settings.endpoint_uri.to_value(),
"cache-control" => settings.cache_control.to_value(),
"content-type" => settings.content_type.to_value(),
"content-disposition" => settings.content_disposition.to_value(),
"content-encoding" => settings.content_encoding.to_value(),
"content-language" => settings.content_language.to_value(),
"force-path-style" => settings.force_path_style.to_value(),
_ => unimplemented!(),
}

View file

@ -72,8 +72,11 @@ struct Settings {
region: Region,
bucket: Option<String>,
key: Option<String>,
cache_control: Option<String>,
content_type: Option<String>,
content_disposition: Option<String>,
content_encoding: Option<String>,
content_language: Option<String>,
access_key: Option<String>,
secret_access_key: Option<String>,
session_token: Option<String>,
@ -129,8 +132,11 @@ impl Default for Settings {
region: Region::new("us-west-2"),
bucket: None,
key: None,
cache_control: None,
content_type: None,
content_disposition: None,
content_encoding: None,
content_language: None,
access_key: None,
secret_access_key: None,
session_token: None,
@ -231,6 +237,11 @@ impl S3PutObjectSink {
let bucket = Some(url.as_ref().unwrap().bucket.to_owned());
let key = Some(url.as_ref().unwrap().object.to_owned());
let cache_control = settings.cache_control.clone();
let content_type = settings.content_type.clone();
let content_disposition = settings.content_disposition.clone();
let content_encoding = settings.content_encoding.clone();
let content_language = settings.content_language.clone();
let metadata = settings.to_metadata(self);
let client = &state.client;
@ -239,6 +250,11 @@ impl S3PutObjectSink {
.put_object()
.set_body(body)
.set_bucket(bucket)
.set_cache_control(cache_control)
.set_content_disposition(content_disposition)
.set_content_encoding(content_encoding)
.set_content_type(content_type)
.set_content_language(content_language)
.set_key(key)
.set_metadata(metadata)
}
@ -422,6 +438,10 @@ impl ObjectImpl for S3PutObjectSink {
.nick("S3 endpoint URI")
.blurb("The S3 endpoint URI to use")
.build(),
glib::ParamSpecString::builder("cache-control")
.nick("cache-control")
.blurb("Cache-Control header to set for uploaded object")
.build(),
glib::ParamSpecString::builder("content-type")
.nick("content-type")
.blurb("Content-Type header to set for uploaded object")
@ -430,6 +450,14 @@ impl ObjectImpl for S3PutObjectSink {
.nick("content-disposition")
.blurb("Content-Disposition header to set for uploaded object")
.build(),
glib::ParamSpecString::builder("content-encoding")
.nick("content-encoding")
.blurb("Content-Encoding header to set for uploaded object")
.build(),
glib::ParamSpecString::builder("content-language")
.nick("content-language")
.blurb("Content-Language header to set for uploaded object")
.build(),
glib::ParamSpecUInt64::builder("flush-interval-buffers")
.nick("Flush interval in buffers")
.blurb("Number of buffers to accumulate before doing a write (0 => disable)")
@ -526,6 +554,11 @@ impl ObjectImpl for S3PutObjectSink {
let _ = self.set_uri(Some(&settings.to_uri()));
}
}
"cache-control" => {
settings.cache_control = value
.get::<Option<String>>()
.expect("type checked upstream");
}
"content-type" => {
settings.content_type = value
.get::<Option<String>>()
@ -536,6 +569,16 @@ impl ObjectImpl for S3PutObjectSink {
.get::<Option<String>>()
.expect("type checked upstream");
}
"content-encoding" => {
settings.content_encoding = value
.get::<Option<String>>()
.expect("type checked upstream");
}
"content-language" => {
settings.content_language = value
.get::<Option<String>>()
.expect("type checked upstream");
}
"flush-interval-buffers" => {
settings.flush_interval_buffers =
value.get::<u64>().expect("type checked upstream");
@ -581,8 +624,11 @@ impl ObjectImpl for S3PutObjectSink {
"retry-attempts" => settings.retry_attempts.to_value(),
"request-timeout" => duration_to_millis(Some(settings.request_timeout)).to_value(),
"endpoint-uri" => settings.endpoint_uri.to_value(),
"cache-control" => settings.cache_control.to_value(),
"content-type" => settings.content_type.to_value(),
"content-disposition" => settings.content_disposition.to_value(),
"content-encoding" => settings.content_encoding.to_value(),
"content-language" => settings.content_language.to_value(),
"flush-interval-buffers" => settings.flush_interval_buffers.to_value(),
"flush-interval-bytes" => settings.flush_interval_bytes.to_value(),
"flush-interval-time" => settings.flush_interval_time.to_value(),