### List Objects Specification and Examples Source: https://ex-aws-s3.hexdocs.pm/ Defines the specification for listing objects in a bucket and provides examples for various filtering and streaming configurations. ```elixir @spec list_objects(bucket :: binary(), opts :: list_objects_opts()) :: ExAws.Operation.S3.t() ``` ```elixir S3.list_objects("my-bucket") |> ExAws.request S3.list_objects("my-bucket") |> ExAws.stream! S3.list_objects("my-bucket", delimiter: "/", prefix: "backup") |> ExAws.stream! S3.list_objects("my-bucket", prefix: "some/inner/location/path") |> ExAws.stream! S3.list_objects("my-bucket", max_keys: 5, encoding_type: "url") |> ExAws.stream! ``` -------------------------------- ### List Object Versions Specification and Examples Source: https://ex-aws-s3.hexdocs.pm/ Defines the specification for listing object versions and provides examples for requesting or streaming results. ```elixir @spec list_object_versions(bucket :: binary(), opts :: list_object_versions_opts()) :: ExAws.Operation.S3.t() ``` ```elixir S3.list_object_versions("my-bucket") |> ExAws.request S3.list_object_versions("my-bucket") |> ExAws.stream! S3.list_object_versions("my-bucket", prefix: "backup/") |> ExAws.stream! ``` -------------------------------- ### Configure bucket replication Source: https://ex-aws-s3.hexdocs.pm/ Examples for setting up cross-region replication using simple and advanced configurations. ```elixir # Simple replication to another region ExAws.S3.put_bucket_replication("my-bucket", role: "arn:aws:iam::123456789012:role/replication-role", destination_bucket: "arn:aws:s3:::backup-bucket", storage_class: "STANDARD_IA" ) ``` ```elixir ExAws.S3.put_bucket_replication("my-bucket", %{ role: "arn:aws:iam::123456789012:role/replication-role", rules: [%{ id: "ReplicateEverything", status: "Enabled", filter: %{prefix: "documents/"}, destination: %{ bucket: "arn:aws:s3:::backup-bucket", storage_class: "STANDARD_IA", access_control_translation: %{owner: "Destination"}, account: "123456789012" } }] }) ``` -------------------------------- ### Configure bucket request payment Source: https://ex-aws-s3.hexdocs.pm/ Examples for setting the payer for requests and data transfer costs. ```elixir # Make requesters pay for downloads ExAws.S3.put_bucket_request_payment("my-bucket", :requester) # Bucket owner pays (default) ExAws.S3.put_bucket_request_payment("my-bucket", :bucket_owner) ``` -------------------------------- ### Install ExAws.S3 dependencies Source: https://ex-aws-s3.hexdocs.pm/ Add the required dependencies to your mix.exs file to enable S3 functionality. ```elixir def deps do [ {:ex_aws, "~> 2.0"}, {:ex_aws_s3, "~> 2.0"}, {:poison, "~> 3.0"}, {:hackney, "~> 1.9"}, {:sweet_xml, "~> 0.6.6"}, # optional dependency ] end ``` -------------------------------- ### Format Lifecycle Rule Configuration Source: https://ex-aws-s3.hexdocs.pm/ Example map structure for defining lifecycle rules, including filters and various expiration or transition actions. ```elixir %{ # Unique id for the rule (max. 255 chars, max. 1000 rules allowed) id: "123", # Disabled rules are not executed enabled: true, # Filters # Can be based on prefix, object tag(s), both or none filter: %{ prefix: "prefix/", tags: %{ "key" => "value" } }, # Actions # https://docs.aws.amazon.com/AmazonS3/latest/dev/intro-lifecycle-rules.html#intro-lifecycle-rules-actions actions: %{ transition: %{ trigger: {:date, ~D[2020-03-26]}, # Date or days based storage: "" }, expiration: %{ trigger: {:days, 2}, # Date or days based expired_object_delete_marker: true }, noncurrent_version_transition: %{ trigger: {:days, 2}, # Only days based storage: "" }, noncurrent_version_expiration: %{ trigger: {:days, 2} # Only days based newer_noncurrent_versions: 10 }, abort_incomplete_multipart_upload: %{ trigger: {:days, 2} # Only days based } } } ``` -------------------------------- ### Get bucket website specification Source: https://ex-aws-s3.hexdocs.pm/ Returns an ExAws operation for retrieving bucket website configuration. ```elixir @spec get_bucket_website(bucket :: binary()) :: ExAws.Operation.S3.t() ``` -------------------------------- ### Generate a Pre-signed URL Source: https://ex-aws-s3.hexdocs.pm/ Example usage of the presigned_url function to generate a URL for an S3 object using default configuration. ```elixir :s3 |> ExAws.Config.new([]) |> ExAws.S3.presigned_url(:get, "my-bucket", "my-object", []) ``` -------------------------------- ### Get object from bucket Source: https://ex-aws-s3.hexdocs.pm/ Retrieves an object from S3. Supports optional versioning parameters. ```elixir @spec get_object(bucket :: binary(), object :: binary(), opts :: get_object_opts()) :: ExAws.Operation.S3.t() ``` ```elixir S3.get_object("my-bucket", "image.png") S3.get_object("my-bucket", "image.png", version_id: "ae57ekgXPpdiVZLkYVWoTAGRhGJ5swt9") ``` -------------------------------- ### Get bucket versioning specification Source: https://ex-aws-s3.hexdocs.pm/ Returns an ExAws operation for retrieving bucket versioning configuration. ```elixir @spec get_bucket_versioning(bucket :: binary()) :: ExAws.Operation.S3.t() ``` -------------------------------- ### Get bucket tagging specification Source: https://ex-aws-s3.hexdocs.pm/ Returns an ExAws operation for retrieving bucket tags. ```elixir @spec get_bucket_tagging(bucket :: binary()) :: ExAws.Operation.S3.t() ``` -------------------------------- ### Get object tagging specification Source: https://ex-aws-s3.hexdocs.pm/ Returns an ExAws operation for retrieving object tags. ```elixir @spec get_object_tagging(bucket :: binary(), object :: binary(), opts :: Keyword.t()) :: ExAws.Operation.S3.t() ``` -------------------------------- ### Get object torrent specification Source: https://ex-aws-s3.hexdocs.pm/ Returns an ExAws operation for retrieving a torrent file for an object. ```elixir @spec get_object_torrent(bucket :: binary(), object :: binary()) :: ExAws.Operation.S3.t() ``` -------------------------------- ### Define initiate_multipart_upload_opt() and initiate_multipart_upload_opts() types Source: https://ex-aws-s3.hexdocs.pm/ Defines individual options and the list type for initiating multipart uploads. ```elixir @type initiate_multipart_upload_opt() :: {:cache_control, binary()} | {:content_disposition, binary()} | {:content_encoding, binary()} | {:content_type, binary()} | {:expires, binary()} | {:website_redirect_location, binary()} | {:encryption, encryption_opts()} | {:meta, amz_meta_opts()} | acl_opt() | storage_class_opt() ``` ```elixir @type initiate_multipart_upload_opts() :: [initiate_multipart_upload_opt()] ``` -------------------------------- ### initiate_multipart_upload(bucket, object, opts) Source: https://ex-aws-s3.hexdocs.pm/ Initiates a multipart upload for a specified object in a bucket. ```APIDOC ## initiate_multipart_upload(bucket, object, opts) ### Description Initiate a multipart upload. ### Signature `initiate_multipart_upload(bucket :: binary(), object :: binary(), opts :: initiate_multipart_upload_opts()) :: ExAws.Operation.S3.t()` ``` -------------------------------- ### put_bucket_website(bucket, website_config) Source: https://ex-aws-s3.hexdocs.pm/ Updates or creates a bucket website configuration to enable static website hosting. ```APIDOC ## put_bucket_website(bucket, website_config) ### Description Update or create a bucket website configuration. Enables static website hosting for the bucket. ### Parameters - **bucket** (binary) - Required - The name of the bucket. - **website_config** (Access.t) - Required - A map or keyword list containing website configuration details such as index_document, error_document, or redirect_all_requests_to. ``` -------------------------------- ### Generate presigned URLs with bucket as host Source: https://ex-aws-s3.hexdocs.pm/ Configure virtual host settings to generate presigned URLs for custom domains. ```elixir opts = [virtual_host: true, bucket_as_host: true] ExAws.Config.new(:s3) |> S3.presigned_url(:get, "bucket.custom-domain.com", "foo.txt", opts) {:ok, "https://bucket.custom-domain.com/foo.txt"} ``` -------------------------------- ### upload(source, bucket, path, opts) Source: https://ex-aws-s3.hexdocs.pm/ Performs a multipart upload to S3, handling initialization and concurrent part uploads. ```APIDOC ## upload(source, bucket, path, opts) ### Description Multipart upload to S3. Handles initialization, uploading parts concurrently, and multipart upload completion. ### Parameters - **source** (Enumerable.t) - Required - The source data stream. - **bucket** (String.t) - Required - The target bucket. - **path** (String.t) - Required - The target path/key. - **opts** (upload_opts) - Optional - Configuration options including :max_concurrency, :timeout, and :refetch_auth_on_request. ``` -------------------------------- ### Define download_file_opts type Source: https://ex-aws-s3.hexdocs.pm/ Represents configuration options for file downloads. ```elixir @type download_file_opts() :: [ max_concurrency: pos_integer(), chunk_size: pos_integer(), timeout: pos_integer() ] ``` -------------------------------- ### Define presigned_url_opts type Source: https://ex-aws-s3.hexdocs.pm/ Configuration options for generating a presigned URL. ```elixir @type presigned_url_opts() :: [ expires_in: expires_in_seconds(), virtual_host: boolean(), s3_accelerate: boolean(), query_params: [{binary(), binary()}], headers: [{binary(), binary()}], bucket_as_host: boolean(), start_datetime: Calendar.naive_datetime() | :calendar.datetime() ] ``` -------------------------------- ### Get object ACL specification Source: https://ex-aws-s3.hexdocs.pm/ Returns an ExAws operation for retrieving an object's access control policy. ```elixir @spec get_object_acl(bucket :: binary(), object :: binary(), opts :: Keyword.t()) :: ExAws.Operation.S3.t() ``` -------------------------------- ### Update bucket website configuration Source: https://ex-aws-s3.hexdocs.pm/ Configures static website hosting for an S3 bucket, supporting simple index documents, error documents, routing rules, and full redirects. ```elixir # Simple website with defaults ExAws.S3.put_bucket_website("my-bucket", index_document: "index.html") # With error document ExAws.S3.put_bucket_website("my-bucket", index_document: "index.html", error_document: "error.html" ) # Full configuration with redirects ExAws.S3.put_bucket_website("my-bucket", %{ index_document: "index.html", error_document: "error.html", routing_rules: [%{ condition: %{key_prefix_equals: "docs/"}, redirect: %{replace_key_prefix_with: "documents/"} }] }) # Redirect all requests to another host ExAws.S3.put_bucket_website("my-bucket", redirect_all_requests_to: %{host_name: "example.com", protocol: "https"} ) ``` -------------------------------- ### list_object_versions(bucket, opts) Source: https://ex-aws-s3.hexdocs.pm/ Lists metadata about all versions of the objects in a bucket. ```APIDOC ## list_object_versions(bucket, opts) ### Description List metadata about all versions of the objects in a bucket. Can be streamed. ### Signature `list_object_versions(bucket :: binary(), opts :: list_object_versions_opts()) :: ExAws.Operation.S3.t()` ### Examples ```elixir S3.list_object_versions("my-bucket") |> ExAws.request S3.list_object_versions("my-bucket") |> ExAws.stream! S3.list_object_versions("my-bucket", prefix: "backup/") |> ExAws.stream! ``` ``` -------------------------------- ### Define list_object_versions_opts() type Source: https://ex-aws-s3.hexdocs.pm/ Defines the options available for listing object versions. ```elixir @type list_object_versions_opts() :: [ delimiter: binary(), key_marker: binary(), version_id_marker: binary(), max_keys: 0..1000, prefix: binary(), encoding_type: binary() ] ``` -------------------------------- ### presigned_post(config, bucket, key, opts) Source: https://ex-aws-s3.hexdocs.pm/ Generates a pre-signed post for an object. ```APIDOC ## presigned_post(config, bucket, key, opts) ### Description Generate a pre-signed post for an object. ### Parameters - **config** (map) - Required - Configuration map. - **bucket** (binary) - Required - The name of the bucket. - **key** (binary|nil) - Required - The object key. - **opts** (presigned_post_opts) - Optional - Additional options for the pre-signed post. ``` -------------------------------- ### Retrieve Bucket Logging Source: https://ex-aws-s3.hexdocs.pm/ Fetches the logging configuration for the specified bucket. ```elixir @spec get_bucket_logging(bucket :: binary()) :: ExAws.Operation.S3.t() ``` -------------------------------- ### Configure S3 endpoint Source: https://ex-aws-s3.hexdocs.pm/ Set custom scheme, host, and port to connect to local instances like Minio. ```elixir # config.exs config :ex_aws, :s3, scheme: "http://", host: "localhost", port: 9000 ``` -------------------------------- ### Retrieve Bucket Lifecycle Source: https://ex-aws-s3.hexdocs.pm/ Fetches the lifecycle configuration for the specified bucket. ```elixir @spec get_bucket_lifecycle(bucket :: binary()) :: ExAws.Operation.S3.t() ``` -------------------------------- ### list_objects(bucket, opts) Source: https://ex-aws-s3.hexdocs.pm/ Lists objects in a specified bucket. ```APIDOC ## list_objects(bucket, opts) ### Description List objects in bucket. Can be streamed. ### Signature `list_objects(bucket :: binary(), opts :: list_objects_opts()) :: ExAws.Operation.S3.t()` ### Examples ```elixir S3.list_objects("my-bucket") |> ExAws.request S3.list_objects("my-bucket") |> ExAws.stream! S3.list_objects("my-bucket", delimiter: "/", prefix: "backup") |> ExAws.stream! S3.list_objects("my-bucket", prefix: "some/inner/location/path") |> ExAws.stream! S3.list_objects("my-bucket", max_keys: 5, encoding_type: "url") |> ExAws.stream! ``` ``` -------------------------------- ### Define presigned_post_opts type Source: https://ex-aws-s3.hexdocs.pm/ Configuration options for generating a presigned POST request. ```elixir @type presigned_post_opts() :: [ expires_in: expires_in_seconds(), acl: binary() | {:starts_with, binary()}, content_length_range: [integer()], key: binary() | {:starts_with, binary()}, custom_conditions: [any()], virtual_host: boolean(), s3_accelerate: boolean(), bucket_as_host: boolean() ] ``` -------------------------------- ### get_bucket_website(bucket) Source: https://ex-aws-s3.hexdocs.pm/ Retrieves the website configuration for a specified S3 bucket. ```APIDOC ## get_bucket_website(bucket) ### Description Retrieves the website configuration for a specified S3 bucket. ### Parameters - **bucket** (binary) - Required - The name of the bucket. ``` -------------------------------- ### download_file(bucket, path, dest, opts) Source: https://ex-aws-s3.hexdocs.pm/ Downloads an S3 object to a file or memory using concurrent parts. ```APIDOC ## download_file(bucket, path, dest, opts) ### Description Download an S3 object to a file. This operation downloads multiple parts of an S3 object concurrently. ### Parameters - **bucket** (binary) - Required - The name of the bucket. - **path** (binary) - Required - The path to the object. - **dest** (:memory | binary) - Required - Destination path or :memory. - **opts** (list) - Optional - Download options. ``` -------------------------------- ### list_parts(bucket, object, upload_id, opts) Source: https://ex-aws-s3.hexdocs.pm/ Lists the parts of a multipart upload for a specific object. ```APIDOC ## list_parts(bucket, object, upload_id, opts) ### Description List the parts of a multipart upload. ### Parameters - **bucket** (binary) - Required - The name of the bucket. - **object** (binary) - Required - The object key. - **upload_id** (binary) - Required - The upload ID. - **opts** (Keyword.t) - Optional - Additional options. ``` -------------------------------- ### Retrieve Bucket Replication Source: https://ex-aws-s3.hexdocs.pm/ Fetches the replication configuration for the specified bucket. ```elixir @spec get_bucket_replication(bucket :: binary()) :: ExAws.Operation.S3.t() ``` -------------------------------- ### presigned_url(config, http_method, bucket, object, opts) Source: https://ex-aws-s3.hexdocs.pm/ Generates a pre-signed URL for an S3 object. ```APIDOC ## presigned_url(config, http_method, bucket, object, opts) ### Description Generate a pre-signed URL for an object. This is a local operation and does not check whether the bucket or object exists. ### Parameters - **config** (map) - Required - **http_method** (string) - Required - **bucket** (string) - Required - **object** (string) - Required - **opts** (list) - Optional ``` -------------------------------- ### Configure S3 bucket notifications Source: https://ex-aws-s3.hexdocs.pm/ Sets up event notifications for S3 buckets, supporting SNS, Lambda, SQS, and custom webhook configurations. ```elixir @spec put_bucket_notification(bucket :: binary(), notification_config :: Access.t()) :: ExAws.Operation.S3.t() ``` ```elixir # SNS notification ExAws.S3.put_bucket_notification("my-bucket", topic_arn: "arn:aws:sns:us-east-1:123456789012:my-topic", events: ["s3:ObjectCreated:*", "s3:ObjectRemoved:*"] ) # Lambda notification with filters ExAws.S3.put_bucket_notification("my-bucket", lambda_function_arn: "arn:aws:lambda:us-east-1:123456789012:function:my-function", events: ["s3:ObjectCreated:Put"], prefix: "uploads/", suffix: ".jpg" ) # SQS notification ExAws.S3.put_bucket_notification("my-bucket", queue_arn: "arn:aws:sqs:us-east-1:123456789012:my-queue", events: ["s3:ObjectCreated:*"] ) ``` ```elixir # Multiple notification types ExAws.S3.put_bucket_notification("my-bucket", %{ topic_configurations: [%{ id: "image-processing", topic_arn: "arn:aws:sns:us-east-1:123456789012:image-topic", events: ["s3:ObjectCreated:*"], filter: %{key: %{filter_rules: [%{name: "prefix", value: "images/"}]}} }], lambda_configurations: [%{ id: "thumbnail-generator", lambda_function_arn: "arn:aws:lambda:us-east-1:123456789012:function:thumbs", events: ["s3:ObjectCreated:Put", "s3:ObjectCreated:Post"] }] }) # MinIO webhook configuration (uses QueueConfiguration with special ARN) ExAws.S3.put_bucket_notification("my-bucket", %{ queue_configurations: [%{ id: "webhook-notifier", queue_arn: "arn:minio:sqs::webhook-target:webhook", events: ["s3:ObjectCreated:*"], filter: %{key: %{filter_rules: [ %{name: "prefix", value: "uploads/"}, %{name: "suffix", value: ".jpg"} ]}} }] }) ``` -------------------------------- ### Generate a pre-signed post Source: https://ex-aws-s3.hexdocs.pm/ Creates a pre-signed post configuration for uploading objects. Supports virtual host, S3 accelerate, and custom bucket host configurations. ```elixir @spec presigned_post( config :: map(), bucket :: binary(), key :: binary() | nil, opts :: presigned_post_opts() ) :: presigned_post_result() ``` -------------------------------- ### Configure S3 bucket logging Source: https://ex-aws-s3.hexdocs.pm/ Updates or creates a bucket logging configuration to enable server access logging. ```elixir @spec put_bucket_logging(bucket :: binary(), logging_config :: Access.t()) :: ExAws.Operation.S3.t() ``` ```elixir # Simple logging to another bucket ExAws.S3.put_bucket_logging("my-bucket", target_bucket: "my-logs-bucket") # With custom prefix ExAws.S3.put_bucket_logging("my-bucket", target_bucket: "my-logs-bucket", target_prefix: "access-logs/" ) # Using a map ExAws.S3.put_bucket_notification("my-bucket", %{ target_bucket: "my-logs-bucket", target_prefix: "logs/my-bucket/" }) ``` -------------------------------- ### list_multipart_uploads(bucket, opts) Source: https://ex-aws-s3.hexdocs.pm/ Lists multipart uploads for a specific bucket. ```APIDOC ## list_multipart_uploads(bucket, opts) ### Description List multipart uploads for a bucket. ### Signature `list_multipart_uploads(bucket :: binary(), opts :: Keyword.t()) :: ExAws.Operation.S3.t()` ``` -------------------------------- ### list_buckets(opts) Source: https://ex-aws-s3.hexdocs.pm/ Lists all buckets owned by the authenticated sender. ```APIDOC ## list_buckets(opts) ### Description List buckets. ### Signature `list_buckets(opts :: Keyword.t()) :: ExAws.Operation.S3.t()` ``` -------------------------------- ### put_bucket_logging(bucket, logging_config) Source: https://ex-aws-s3.hexdocs.pm/ Updates or creates a bucket logging configuration to enable server access logging for the specified bucket. ```APIDOC ## put_bucket_logging(bucket, logging_config) ### Description Enables server access logging for the bucket by updating or creating a logging configuration. ### Signature `put_bucket_logging(bucket :: binary(), logging_config :: Access.t()) :: ExAws.Operation.S3.t()` ### Parameters - **bucket** (binary) - The name of the bucket. - **logging_config** (Access.t) - Configuration map or keyword list containing target_bucket and optional target_prefix. ### Example ```elixir ExAws.S3.put_bucket_logging("my-bucket", target_bucket: "my-logs-bucket", target_prefix: "access-logs/") ``` ``` -------------------------------- ### get_bucket_object_versions(bucket, opts) Source: https://ex-aws-s3.hexdocs.pm/ Lists metadata about all versions of the objects in a bucket. Note: This function is deprecated; use list_object_versions/2 instead. ```APIDOC ## get_bucket_object_versions(bucket, opts) ### Description Lists metadata about all versions of the objects in a bucket. This function is deprecated. Use list_object_versions/2 instead. ### Parameters - **bucket** (binary) - Required - The name of the S3 bucket. - **opts** (Keyword.t) - Optional - Additional options. ``` -------------------------------- ### put_object_copy(dest_bucket, dest_object, src_bucket, src_object, opts) Source: https://ex-aws-s3.hexdocs.pm/ Copies an object from a source location to a destination location. ```APIDOC ## put_object_copy(dest_bucket, dest_object, src_bucket, src_object, opts) ### Description Copy an object. ### Parameters - **dest_bucket** (binary) - Required - The destination bucket name. - **dest_object** (binary) - Required - The destination object key. - **src_bucket** (binary) - Required - The source bucket name. - **src_object** (binary) - Required - The source object key. - **opts** (put_object_copy_opts) - Optional - Additional copy options. ``` -------------------------------- ### presigned_url(config, http_method, bucket, object, opts) Source: https://ex-aws-s3.hexdocs.pm/ Generates a pre-signed URL for an S3 object. This is a local operation that does not perform network requests to verify the existence of the bucket or object. ```APIDOC ## presigned_url(config, http_method, bucket, object, opts) ### Description Generates a pre-signed URL for an S3 object. This is a local operation and does not check whether the bucket or object exists. ### Signature `presigned_url(config :: map(), http_method :: atom(), bucket :: binary(), object :: binary(), opts :: presigned_url_opts()) :: {:ok, binary()} | {:error, binary()}` ### Parameters - **config** (map) - Required - The configuration map for the S3 client. - **http_method** (atom) - Required - The HTTP method (e.g., :get, :put). - **bucket** (binary) - Required - The name of the S3 bucket. - **object** (binary) - Required - The path to the S3 object. - **opts** (list) - Optional - A list of options including :virtual_host, :s3_accelerate, :bucket_as_host, :start_datetime, :query_params, and :headers. ### Example ```elixir :s3 |> ExAws.Config.new([]) |> ExAws.S3.presigned_url(:get, "my-bucket", "my-object", []) ``` ``` -------------------------------- ### List Buckets Specification Source: https://ex-aws-s3.hexdocs.pm/ Defines the specification for listing all buckets in an account. ```elixir @spec list_buckets(opts :: Keyword.t()) :: ExAws.Operation.S3.t() ``` -------------------------------- ### Initiate Multipart Upload Specification Source: https://ex-aws-s3.hexdocs.pm/ Defines the specification for initiating a multipart upload operation. ```elixir @spec initiate_multipart_upload( bucket :: binary(), object :: binary(), opts :: initiate_multipart_upload_opts() ) :: ExAws.Operation.S3.t() ``` -------------------------------- ### Define list_objects_opts type Source: https://ex-aws-s3.hexdocs.pm/ Configuration options for listing objects in an S3 bucket. ```elixir @type list_objects_opts() :: [ delimiter: binary(), marker: binary(), prefix: binary(), encoding_type: binary(), max_keys: 0..1000, stream_prefixes: boolean() ] ``` -------------------------------- ### options_object(bucket, object, origin, request_method, request_headers) Source: https://ex-aws-s3.hexdocs.pm/ Determines the CORS configuration for an object. ```APIDOC ## options_object(bucket, object, origin, request_method, request_headers) ### Description Determine the CORS configuration for an object. ### Parameters - **bucket** (binary) - Required - The name of the bucket. - **object** (binary) - Required - The object key. - **origin** (binary) - Required - The origin header. - **request_method** (atom) - Required - The HTTP method. - **request_headers** (list) - Required - List of request headers. ``` -------------------------------- ### List parts of a multipart upload Source: https://ex-aws-s3.hexdocs.pm/ Lists the uploaded parts for a specific multipart upload session. ```elixir @spec list_parts( bucket :: binary(), object :: binary(), upload_id :: binary(), opts :: Keyword.t() ) :: ExAws.Operation.S3.t() ``` -------------------------------- ### post_object_restore(bucket, object, number_of_days, opts) Source: https://ex-aws-s3.hexdocs.pm/ Restores an object to a particular version. ```APIDOC ## post_object_restore(bucket, object, number_of_days, opts) ### Description Restore an object to a particular version. ### Parameters - **bucket** (binary) - Required - The name of the bucket. - **object** (binary) - Required - The object key. - **number_of_days** (pos_integer) - Required - Number of days to restore. - **opts** (list) - Optional - Options including version_id. ``` -------------------------------- ### Define customer_encryption_opts type Source: https://ex-aws-s3.hexdocs.pm/ Represents options for customer-provided encryption keys. ```elixir @type customer_encryption_opts() :: [ customer_algorithm: binary(), customer_key: binary(), customer_key_md5: binary() ] ``` -------------------------------- ### Define head_object_opt() and head_object_opts() types Source: https://ex-aws-s3.hexdocs.pm/ Defines individual options and the list type for head_object operations. ```elixir @type head_object_opt() :: {:encryption, customer_encryption_opts()} | {:range, binary()} | {:version_id, binary()} | {:if_modified_since, binary()} | {:if_unmodified_since, binary()} | {:if_match, binary()} | {:if_none_match, binary()} ``` ```elixir @type head_object_opts() :: [head_object_opt()] ``` -------------------------------- ### Update bucket versioning Source: https://ex-aws-s3.hexdocs.pm/ Updates or creates a bucket versioning configuration by passing an XML string. ```elixir ExAws.S3.put_bucket_versioning( "my-bucket", "Enabled" ) |> ExAws.request() ``` -------------------------------- ### put_bucket_versioning(bucket, version_config) Source: https://ex-aws-s3.hexdocs.pm/ Updates or creates a bucket versioning configuration. ```APIDOC ## put_bucket_versioning(bucket, version_config) ### Description Update or create a bucket versioning configuration. ### Parameters - **bucket** (binary) - Required - The name of the bucket. - **version_config** (binary) - Required - The XML configuration string for versioning. ``` -------------------------------- ### put_bucket_lifecycle(bucket, lifecycle_rules) Source: https://ex-aws-s3.hexdocs.pm/ Updates or creates a bucket lifecycle configuration. ```APIDOC ## put_bucket_lifecycle(bucket, lifecycle_rules) ### Description Update or create a bucket lifecycle configuration. ### Parameters - **bucket** (binary) - Required - The name of the bucket. - **lifecycle_rules** (list) - Required - A list of maps defining lifecycle rules. ``` -------------------------------- ### put_bucket_tagging(bucket, tags) Source: https://ex-aws-s3.hexdocs.pm/ Updates or creates a bucket tagging configuration. ```APIDOC ## put_bucket_tagging(bucket, tags) ### Description Update or create a bucket tagging configuration. ### Parameters - **bucket** (binary) - Required - The name of the bucket. - **tags** (Access.t) - Required - A map or keyword list of tags to apply to the bucket. ``` -------------------------------- ### Define get_object_opts type Source: https://ex-aws-s3.hexdocs.pm/ Represents options for retrieving an object. ```elixir @type get_object_opts() :: [ {:response, get_object_response_opts()} | {:version_id, binary()} | head_object_opt() ] ``` -------------------------------- ### Define upload_part_copy_opts type Source: https://ex-aws-s3.hexdocs.pm/ Defines options for copying parts during a multipart upload. ```elixir @type upload_part_copy_opts() :: [ copy_source_if_modified_since: binary(), copy_source_if_unmodified_since: binary(), copy_source_if_match: binary(), copy_source_if_none_match: binary(), destination_encryption: encryption_opts(), source_encryption: customer_encryption_opts() ] ``` -------------------------------- ### Update bucket tagging Source: https://ex-aws-s3.hexdocs.pm/ Updates or creates a bucket tagging configuration using either a map or a keyword list. ```elixir # Using a map ExAws.S3.put_bucket_tagging("my-bucket", %{"Environment" => "prod", "Team" => "data"}) # Using a keyword list ExAws.S3.put_bucket_tagging("my-bucket", Environment: "prod", Team: "data") ``` -------------------------------- ### Perform a Multipart Upload Source: https://ex-aws-s3.hexdocs.pm/ExAws.S3.Upload.html Streams a local file and uploads it to an S3 bucket using the multipart upload process. ```elixir "path/to/big/file" |> S3.Upload.stream_file |> S3.upload("my-bucket", "path/on/s3") |> ExAws.request! #=> :done ``` -------------------------------- ### Configure content hash algorithm Source: https://ex-aws-s3.hexdocs.pm/ Specify the content hash algorithm, such as :sha256, for FIPS-compliant environments. ```elixir # config.exs config :ex_aws_s3, :content_hash_algorithm, :sha256 ``` -------------------------------- ### upload_part_copy(dest_bucket, dest_object, src_bucket, src_object, upload_id, part_number, source_range, opts) Source: https://ex-aws-s3.hexdocs.pm/ Uploads a part by copying data from an existing object for a multipart copy operation. ```APIDOC ## upload_part_copy(dest_bucket, dest_object, src_bucket, src_object, upload_id, part_number, source_range, opts) ### Description Upload a part for a multipart copy. ### Parameters - **dest_bucket** (binary) - Required - **dest_object** (binary) - Required - **src_bucket** (binary) - Required - **src_object** (binary) - Required - **upload_id** (binary) - Required - **part_number** (pos_integer) - Required - **source_range** (Range.t) - Required - **opts** (list) - Optional ``` -------------------------------- ### Define get_object_response_opts type Source: https://ex-aws-s3.hexdocs.pm/ Represents response header options for object retrieval. ```elixir @type get_object_response_opts() :: [ content_language: binary(), expires: binary(), cache_control: binary(), content_disposition: binary(), content_encoding: binary() ] ``` -------------------------------- ### Retrieve Bucket Policy Source: https://ex-aws-s3.hexdocs.pm/ Fetches the bucket policy for the specified bucket. ```elixir @spec get_bucket_policy(bucket :: binary()) :: ExAws.Operation.S3.t() ``` -------------------------------- ### stream_file/2 Source: https://ex-aws-s3.hexdocs.pm/ExAws.S3.Upload.html Opens a file stream for use in an upload. The chunk size must be at least 5 MiB, defaulting to 5 MiB. ```APIDOC ## stream_file(path, opts \\ []) ### Description Opens a file stream for use in an upload. Chunk size must be at least 5 MiB. ### Parameters - **path** (binary) - Required - The path to the file to be uploaded. - **opts** (Keyword) - Optional - Options including :chunk_size (pos_integer). ``` -------------------------------- ### Define storage_class_opt type Source: https://ex-aws-s3.hexdocs.pm/ Defines the storage class option tuple. ```elixir @type storage_class_opt() :: {:storage_class, storage_class()} ``` -------------------------------- ### list_objects_v2(bucket, opts) Source: https://ex-aws-s3.hexdocs.pm/ Lists objects in a specified S3 bucket. This operation can be streamed. ```APIDOC ## list_objects_v2(bucket, opts) ### Description List objects in bucket. Can be streamed. ### Parameters - **bucket** (binary) - Required - The name of the bucket. - **opts** (list) - Optional - Additional options for listing objects. ``` -------------------------------- ### put_bucket(bucket, region, opts) Source: https://ex-aws-s3.hexdocs.pm/ Creates a new S3 bucket in the specified region. ```APIDOC ## put_bucket(bucket, region, opts) ### Description Creates a bucket in the specified region. ### Parameters - **bucket** (binary) - Required - The name of the bucket to create. - **region** (binary) - Required - The AWS region for the bucket. - **opts** (list) - Optional - Additional options. ``` -------------------------------- ### Define amz_meta_opts type Source: https://ex-aws-s3.hexdocs.pm/ Represents Amazon metadata options as a list of tuples. ```elixir @type amz_meta_opts() :: [{atom(), binary()} | {binary(), binary()}, ...] ``` -------------------------------- ### Define put_object_copy_opts type Source: https://ex-aws-s3.hexdocs.pm/ Configuration options for copying an object within S3. ```elixir @type put_object_copy_opts() :: [ {:metadata_directive, :COPY | :REPLACE} | {:copy_source_if_modified_since, binary()} | {:copy_source_if_unmodified_since, binary()} | {:copy_source_if_match, binary()} | {:copy_source_if_none_match, binary()} | {:website_redirect_location, binary()} | {:destination_encryption, encryption_opts()} | {:source_encryption, customer_encryption_opts()} | {:cache_control, binary()} | {:content_disposition, binary()} | {:content_encoding, binary()} | {:content_length, binary()} | {:content_type, binary()} | {:expect, binary()} | {:expires, binary()} | {:website_redirect_location, binary()} | {:meta, amz_meta_opts()} | acl_opt() | storage_class_opt() ] ``` -------------------------------- ### Retrieve Bucket Object Versions Source: https://ex-aws-s3.hexdocs.pm/ Lists metadata about all versions of objects in a bucket. This function is deprecated; use list_object_versions/2 instead. ```elixir @spec get_bucket_object_versions(bucket :: binary(), opts :: Keyword.t()) :: ExAws.Operation.S3.t() ``` -------------------------------- ### Stream File Specification Source: https://ex-aws-s3.hexdocs.pm/ExAws.S3.Upload.html Defines the specification for opening a file stream for an upload, requiring a chunk size of at least 5 MiB. ```elixir @spec stream_file(path :: binary(), opts :: [{:chunk_size, pos_integer()}]) :: File.Stream.t() ``` -------------------------------- ### get_object_tagging(bucket, object, opts) Source: https://ex-aws-s3.hexdocs.pm/ Retrieves the tagging configuration for a specified S3 object. ```APIDOC ## get_object_tagging(bucket, object, opts) ### Description Retrieves the tagging configuration for a specified S3 object. ### Parameters - **bucket** (binary) - Required - The name of the bucket. - **object** (binary) - Required - The key of the object. - **opts** (Keyword.t) - Optional - Additional options. ``` -------------------------------- ### S3.download_file/4 Source: https://ex-aws-s3.hexdocs.pm/ExAws.S3.html Downloads a large file from S3 to the local disk. ```APIDOC ## S3.download_file(bucket, path, dest_path, opts \\ []) ### Description Downloads an object from S3 to a local file path. ### Usage ```elixir S3.download_file("my-bucket", "path/on/s3", "path/to/dest/file") |> ExAws.request ``` ``` -------------------------------- ### Define acl_opts type Source: https://ex-aws-s3.hexdocs.pm/ Represents a list of access control list options. ```elixir @type acl_opts() :: [acl_opt()] ``` -------------------------------- ### Perform basic S3 operations Source: https://ex-aws-s3.hexdocs.pm/ Execute standard S3 requests using the ExAws.request! or ExAws.stream! functions. ```elixir S3.list_objects("my-bucket") |> ExAws.request! #=> %{body: [list, of, objects]} S3.list_objects("my-bucket") |> ExAws.stream! |> Enum.to_list #=> [list, of, objects] S3.put_object("my-bucket", "path/to/bucket", contents) |> ExAws.request! ``` -------------------------------- ### put_bucket_policy(bucket, policy) Source: https://ex-aws-s3.hexdocs.pm/ Updates or creates a bucket policy configuration. ```APIDOC ## put_bucket_policy(bucket, policy) ### Description Updates or creates a bucket policy configuration. ### Parameters - **bucket** (binary) - Required - The name of the bucket. - **policy** (String.t) - Required - The policy configuration string. ``` -------------------------------- ### ExAws.S3 SDK Functions Source: https://ex-aws-s3.hexdocs.pm/ExAws.S3.html A collection of functions provided by the ExAws.S3 library to interact with S3 services. ```APIDOC ## ExAws.S3 Functions ### Bucket Operations - `list_buckets(opts \\ [])`: List all buckets. - `put_bucket(bucket, region, opts \\ [])`: Create a bucket in the specified region. - `delete_bucket(bucket)`: Delete a bucket. - `head_bucket(bucket)`: Determine if a bucket exists. ### Object Operations - `get_object(bucket, object, opts \\ [])`: Get an object from a bucket. - `put_object(bucket, object, body, opts \\ [])`: Create an object within a bucket. - `delete_object(bucket, object, opts \\ [])`: Delete an object within a bucket. - `head_object(bucket, object, opts \\ [])`: Determine if an object exists. - `list_objects(bucket, opts \\ [])`: List objects in a bucket. - `list_objects_v2(bucket, opts \\ [])`: List objects in a bucket (v2). ### Multipart Uploads - `initiate_multipart_upload(bucket, object, opts \\ [])`: Initiate a multipart upload. - `upload_part(bucket, object, upload_id, part_number, body, opts \\ [])`: Upload a part for a multipart upload. - `complete_multipart_upload(bucket, object, upload_id, parts)`: Complete a multipart upload. - `abort_multipart_upload(bucket, object, upload_id)`: Abort a multipart upload. ### Pre-signed Operations - `presigned_url(config, http_method, bucket, object, opts \\ [])`: Generate a pre-signed URL for an object. - `presigned_post(config, bucket, key, opts \\ [])`: Generate a pre-signed post for an object. ``` -------------------------------- ### get_bucket_lifecycle(bucket) Source: https://ex-aws-s3.hexdocs.pm/ Retrieves the lifecycle configuration for the specified S3 bucket. ```APIDOC ## get_bucket_lifecycle(bucket) ### Description Retrieves the lifecycle configuration for the specified S3 bucket. ### Parameters - **bucket** (binary) - Required - The name of the S3 bucket. ``` -------------------------------- ### Download large files to disk Source: https://ex-aws-s3.hexdocs.pm/ Download files directly to a destination path on disk. ```elixir S3.download_file("my-bucket", "path/on/s3", "path/to/dest/file") |> ExAws.request #=> {:ok, :done} ``` -------------------------------- ### Retrieve Bucket Notification Source: https://ex-aws-s3.hexdocs.pm/ Fetches the notification configuration for the specified bucket. ```elixir @spec get_bucket_notification(bucket :: binary()) :: ExAws.Operation.S3.t() ``` -------------------------------- ### Define list_objects_v2_opts type Source: https://ex-aws-s3.hexdocs.pm/ Configuration options for the V2 list objects operation. ```elixir @type list_objects_v2_opts() :: [ delimiter: binary(), prefix: binary(), encoding_type: binary(), max_keys: 0..1000, stream_prefixes: boolean(), continuation_token: binary(), fetch_owner: boolean(), start_after: binary() ] ``` -------------------------------- ### get_bucket_tagging(bucket) Source: https://ex-aws-s3.hexdocs.pm/ Retrieves the tagging configuration for a specified S3 bucket. ```APIDOC ## get_bucket_tagging(bucket) ### Description Retrieves the tagging configuration for a specified S3 bucket. ### Parameters - **bucket** (binary) - Required - The name of the bucket. ``` -------------------------------- ### Retrieve Bucket Request Payment Source: https://ex-aws-s3.hexdocs.pm/ Fetches the request payment configuration for the specified bucket. ```elixir @spec get_bucket_request_payment(bucket :: binary()) :: ExAws.Operation.S3.t() ``` -------------------------------- ### get_object(bucket, object, opts) Source: https://ex-aws-s3.hexdocs.pm/ Retrieves an object from the specified S3 bucket. ```APIDOC ## get_object(bucket, object, opts) ### Description Get an object from a bucket. ### Parameters - **bucket** (string) - Required - **object** (string) - Required - **opts** (list) - Optional ``` -------------------------------- ### Define canned_acl type Source: https://ex-aws-s3.hexdocs.pm/ Enumerates supported canned ACL values. ```elixir @type canned_acl() :: :private | :public_read | :public_read_write | :authenticated_read | :bucket_owner_read | :bucket_owner_full_control ``` -------------------------------- ### Define upload_opts type Source: https://ex-aws-s3.hexdocs.pm/ Defines the list type for multipart upload options. ```elixir @type upload_opts() :: [upload_opt()] ``` -------------------------------- ### get_object(bucket, object, opts) Source: https://ex-aws-s3.hexdocs.pm/ Retrieves an object from a specified S3 bucket. ```APIDOC ## get_object(bucket, object, opts) ### Description Retrieves an object from a specified S3 bucket. Optional parameters can be provided to specify versioning. ### Parameters - **bucket** (binary) - Required - The name of the bucket. - **object** (binary) - Required - The key of the object. - **opts** (get_object_opts) - Optional - Additional options like version_id. ``` -------------------------------- ### put_bucket_replication(bucket, replication_config) Source: https://ex-aws-s3.hexdocs.pm/ Updates or creates a bucket replication configuration to manage cross-region replication. ```APIDOC ## put_bucket_replication(bucket, replication_config) ### Description Update or create a bucket replication configuration. Configures cross-region replication for the bucket. ### Parameters - **bucket** (binary) - Required - The name of the bucket. - **replication_config** (Access.t) - Required - The replication configuration details. ``` -------------------------------- ### Download file Source: https://ex-aws-s3.hexdocs.pm/ Downloads an S3 object to a file or memory using concurrent parts. ```elixir @spec download_file( bucket :: binary(), path :: binary(), dest :: :memory | binary(), opts :: download_file_opts() ) :: ExAws.S3.Download.t() ``` ```elixir ExAws.S3.download_file("example-bucket", "path/to/file.txt", :memory) |> ExAws.stream!() ``` ```elixir # Returns a stream which grabs chunks of data from S3 as specified in `opts` # but processes the stream line by line. For example, the default chunk # size of 1MB means requests for bytes from S3 will ask for 1MB sizes (to be downloaded) # however each element of the stream will be a single line. def generate_stream(bucket, file, opts \\ []) do bucket |> ExAws.S3.download_file(file, :memory, opts) |> ExAws.stream!() # Uncomment if you need to gunzip (and add dependency :stream_gzip) # |> StreamGzip.gunzip() |> Stream.chunk_while("", &chunk_fun/2, &to_line_stream_after_fun/1) |> Stream.concat() end def chunk_fun(chunk, acc) do to_try = acc <> chunk {elements, acc} = chunk_by_newline(to_try, "\n", [], {0, byte_size(to_try)}) {:cont, elements, acc} end defp chunk_by_newline(_string, _newline, elements, {_offset, 0}) do {Enum.reverse(elements), ""} end defp chunk_by_newline(string, newline, elements, {offset, length}) do case :binary.match(string, newline, scope: {offset, length}) do {newline_offset, newline_length} -> difference = newline_length + newline_offset - offset element = binary_part(string, offset, difference) chunk_by_newline( string, newline, [element | elements], {newline_offset + newline_length, length - difference} ) :nomatch -> {Enum.reverse(elements), binary_part(string, offset, length)} end end defp to_line_stream_after_fun(""), do: {:cont, []} defp to_line_stream_after_fun(acc), do: {:cont, [acc], []} ``` -------------------------------- ### get_bucket_versioning(bucket) Source: https://ex-aws-s3.hexdocs.pm/ Retrieves the versioning configuration for a specified S3 bucket. ```APIDOC ## get_bucket_versioning(bucket) ### Description Retrieves the versioning configuration for a specified S3 bucket. ### Parameters - **bucket** (binary) - Required - The name of the bucket. ``` -------------------------------- ### List Multipart Uploads Specification Source: https://ex-aws-s3.hexdocs.pm/ Defines the specification for listing multipart uploads within a specific bucket. ```elixir @spec list_multipart_uploads(bucket :: binary(), opts :: Keyword.t()) :: ExAws.Operation.S3.t() ``` -------------------------------- ### Define delete_object_opts type Source: https://ex-aws-s3.hexdocs.pm/ Represents a list of delete object options. ```elixir @type delete_object_opts() :: [delete_object_opt()] ``` -------------------------------- ### put_object_tagging(bucket, object, tags, opts) Source: https://ex-aws-s3.hexdocs.pm/ Adds a set of tags to an existing object. ```APIDOC ## put_object_tagging(bucket, object, tags, opts) ### Description Add a set of tags to an existing object. ### Parameters - **bucket** (binary) - Required - The name of the bucket. - **object** (binary) - Required - The key of the object. - **tags** (Access.t) - Required - The tags to apply. - **opts** (Keyword.t) - Optional - Additional options, including :version_id. ``` -------------------------------- ### Define storage_class type Source: https://ex-aws-s3.hexdocs.pm/ Lists the supported S3 storage classes. ```elixir @type storage_class() :: :standard | :reduced_redundancy | :standard_ia | :onezone_ia | :intelligent_tiering | :glacier | :deep_archive | :outposts | :glacier_ir | :snow ```