Skip to content

Add system-defined metadata options to awss3sink and awss3putobjectsink

Liam Wall requested to merge ljwall/gst-plugins-rs:add-cache-control into main

Purpose

Add system-defined metadata options to awss3sink and awss3putobjectsink

#542

The ticket mentions the Expires header, and there are other meta-data options (e.g. ACL) but I've left these out as non-string options are outside of my limited Rust knowledge 😀

Approach

Following the pattern of other string system-meta data parameters, add to both elements the following parameters which are then set on the S3 upload commands:

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

Bugfix

In doing this I noticed that the content-type and content-disposition parameters on awss3putobjectsink seemed to be unused, so have added those to the put_object call.

Testing

No automated testing, but have tested manually to confirm that the elements work as expected with and without the parameters applied.

awss3sink

Without parameters set

GST_PLUGIN_PATH="target/x86_64-unknown-linux-gnu/debug:$GST_PLUGIN_PATH" gst-launch-1.0 filesrc location=/dev/random num-buffers=2500 blocksize=4096 ! \
  awss3sink bucket=gst-plugins-rs-aws-s3-testing key=no-headers region=us-east-1

Result:

$ aws s3api head-object --bucket gst-plugins-rs-aws-s3-testing --key no-headers
{
    "AcceptRanges": "bytes",
    "LastModified": "2024-05-19T20:06:57+00:00",
    "ContentLength": 10240000,
    "ETag": "\"603674844da359f2568ab5cf86e57727-2\"",
    "ContentType": "binary/octet-stream",
    "ServerSideEncryption": "AES256",
    "Metadata": {}
}

With parameters set

GST_PLUGIN_PATH="target/x86_64-unknown-linux-gnu/debug:$GST_PLUGIN_PATH" gst-launch-1.0 filesrc location=/dev/random num-buffers=2500 blocksize=4096 ! \
  awss3sink bucket=gst-plugins-rs-aws-s3-testing key=with-headers.gzip region=us-east-1 cache-control='max-age=60' content-encoding=gzip content-language=en-GB

Result:

$ aws s3api head-object --bucket gst-plugins-rs-aws-s3-testing --key with-headers.gzip
{
    "AcceptRanges": "bytes",
    "LastModified": "2024-05-19T20:13:31+00:00",
    "ContentLength": 10240000,
    "ETag": "\"f60d87eae595c554b7dd3ddd68810ceb-2\"",
    "CacheControl": "max-age=60",
    "ContentEncoding": "gzip",
    "ContentLanguage": "en-GB",
    "ContentType": "binary/octet-stream",
    "ServerSideEncryption": "AES256",
    "Metadata": {}
}

awss3putobjectsink

Without parameters set

GST_PLUGIN_PATH="target/x86_64-unknown-linux-gnu/debug:$GST_PLUGIN_PATH" gst-launch-1.0 filesrc location=/dev/random num-buffers=10 blocksize=4096 ! \
    awss3putobjectsink bucket=gst-plugins-rs-aws-s3-testing key=no-headers-putobject region=us-east-1

Result:

$ aws s3api head-object --bucket gst-plugins-rs-aws-s3-testing --key no-headers-putobject
{
    "AcceptRanges": "bytes",
    "LastModified": "2024-05-24T09:20:41+00:00",
    "ContentLength": 40960,
    "ETag": "\"840ee66dbcbbc9f116a89352dec6ac9b\"",
    "ContentType": "application/octet-stream",
    "ServerSideEncryption": "AES256",
    "Metadata": {}
}

With parameters set

(also testing content-type and content-disposition)

GST_PLUGIN_PATH="target/x86_64-unknown-linux-gnu/debug:$GST_PLUGIN_PATH" gst-launch-1.0 filesrc location=/dev/random num-buffers=10 blocksize=4096 ! \
   awss3putobjectsink bucket=gst-plugins-rs-aws-s3-testing key=with-headers-putobject region=us-east-1 cache-control='max-age=60' content-encoding=gzip content-language=en-GB content-type=application/pdf content-disposition=attachment

Result:

$ aws s3api head-object --bucket gst-plugins-rs-aws-s3-testing --key with-headers-putobject
{
    "AcceptRanges": "bytes",
    "LastModified": "2024-05-24T09:24:06+00:00",
    "ContentLength": 40960,
    "ETag": "\"8aac9f4bfd021f601f62f96211306a23\"",
    "CacheControl": "max-age=60",
    "ContentDisposition": "attachment",
    "ContentEncoding": "gzip",
    "ContentLanguage": "en-GB",
    "ContentType": "application/pdf",
    "ServerSideEncryption": "AES256",
    "Metadata": {}
}

Merge request reports