AWSS3.jl

AWS S3

https://github.com/samoconnor/AWSS3.jl

AWS S3 Objects

AWSS3.s3_getFunction.
s3_get([::AWSConfig], bucket, path; <keyword arguments>)

Get Object from path in bucket.

Optional Arguments

  • version=: version of object to get.

  • retry=true: try again on "NoSuchBucket", "NoSuchKey" (common if object was recently created).

  • raw=false: return response as Vector{UInt8} (by default return type depends on Content-Type header).

AWSS3.s3_get_fileFunction.
s3_get_file([::AWSConfig], bucket, path, filename; [version=])

Like s3_get but streams result directly to filename.

AWSS3.s3_get_metaFunction.

s3_get_meta([::AWSConfig], bucket, path; [version=])

HEAD Object

Retrieves metadata from an object without returning the object itself.

AWSS3.s3_existsFunction.
s3_exists([::AWSConfig], bucket, path [version=])

Is there an object in bucket at path?

AWSS3.s3_putFunction.
s3_put([::AWSConfig], bucket, path, data; <keyword arguments>

PUT Object data at path in bucket.

Optional Arguments

  • data_type=; Content-Type header.

  • encoding=; Content-Encoding header.

  • metadata::Dict=; x-amz-meta- headers.

  • tags::Dict=; x-amz-tagging- headers (see also s3_put_tags and s3_get_tags).

s3_purge_versions([::AWSConfig], bucket, [path [, pattern]])

DELETE all object versions except for the latest version.

AWSS3.s3_deleteFunction.
s3_delete([::AWSConfig], bucket, path; [version=]

DELETE Object

AWSS3.s3_copyFunction.
s3_copy([::AWSConfig], bucket, path; to_bucket=bucket, to_path=path)

PUT Object - Copy

Optional Arguments

  • metadata::Dict=; optional x-amz-meta- headers.

AWSS3.s3_sign_urlFunction.
s3_sign_url([::AWSConfig], bucket, path, [seconds=3600];
            [verb="GET"], [content_type="application/octet-stream"])

Create a pre-signed url for bucket and path (expires after for seconds).

To create an upload URL use verb="PUT" and set content_type to match the type used in the Content-Type header of the PUT request.

url = s3_sign_url("my_bucket", "my_file.txt"; verb="PUT")
Requests.put(URI(url), "Hello!")
url = s3_sign_url("my_bucket", "my_file.txt";
                  verb="PUT", content_type="text/plain")

Requests.put(URI(url), "Hello!";
             headers=Dict("Content-Type" => "text/plain"))

AWS S3 Buckets

AWSS3.s3_list_bucketsFunction.
s3_list_buckets([::AWSConfig])

List of all buckets owned by the sender of the request.

AWSS3.s3_list_objectsFunction.
s3_list_objects([::AWSConfig], bucket, [path_prefix])

List Objects in bucket with optional path_prefix.

Returns Vector{Dict} with keys Key, LastModified, ETag, Size, Owner, StorageClass.

s3_list_versions([::AWSConfig], bucket, [path_prefix])

List object versions in bucket with optional path_prefix.

s3_create_bucket([:AWSConfig], bucket)

PUT Bucket

AWSS3.s3_put_corsFunction.
s3_put_cors([::AWSConfig], bucket, cors_config)

PUT Bucket cors

s3_put_cors("my_bucket", """
    <?xml version="1.0" encoding="UTF-8"?>
    <CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
        <CORSRule>
            <AllowedOrigin>http://my.domain.com</AllowedOrigin>
            <AllowedOrigin>http://my.other.domain.com</AllowedOrigin>
            <AllowedMethod>GET</AllowedMethod>
            <AllowedMethod>HEAD</AllowedMethod>
            <AllowedHeader>*</AllowedHeader>
            <ExposeHeader>Content-Range</ExposeHeader>
        </CORSRule>
    </CORSConfiguration>
"""
s3_enable_versioning([::AWSConfig], bucket)

Enable versioning for bucket.

s3_delete_bucket([::AWSConfig], "bucket")

DELETE Bucket.

AWS S3 Bucket and Object Tagging

AWSS3.s3_put_tagsFunction.
s3_put_tags([::AWSConfig], bucket, [path,] tags::Dict)

PUT tags on bucket or object (path).

See also tags= option on s3_put.

AWSS3.s3_get_tagsFunction.
s3_get_tags([::AWSConfig], bucket, [path])

Get tags from bucket or object (path).

AWSS3.s3_delete_tagsFunction.
s3_delete_tags([::AWSConfig], bucket, [path])

Delete tags from bucket or object (path).

AWSS3 Internals

AWSS3.s3_arnFunction.
s3_arn(resource)
s3_arn(bucket,path)

Amazon Resource Name for S3 resource or bucket and path.

s3_arn("my_bucket/foo/bar.txt")
"arn:aws:s3:::my_bucket/foo/bar.txt"
s3_arn("my_bucket","foo/bar.txt")
"arn:aws:s3:::my_bucket/foo/bar.txt"