# `SiteMaps.Adapters.S3`
[🔗](https://github.com/marcosgz/site_maps_ex/blob/v0.1.0/lib/site_maps/adapters/s3.ex#L1)

Stores sitemaps in AWS S3 or any S3-compatible service (MinIO, DigitalOcean
Spaces, Wasabi, Ceph, Google Cloud Storage interoperability).

Requires the optional dependencies `ex_aws`, `ex_aws_s3` and an HTTP client
supported by ExAws, such as `req`:

    {:ex_aws, "~> 2.5"},
    {:ex_aws_s3, "~> 2.5"},
    {:req, "~> 0.5"}

    # config/config.exs
    config :ex_aws, http_client: ExAws.Request.Req

Example:

    adapter: {SiteMaps.Adapters.S3, bucket: "sitemaps", prefix: "acme", region: "us-east-1"}

    adapter:
      {SiteMaps.Adapters.S3,
       bucket: "sitemaps",
       endpoint: "http://minio:9000",
       access_key_id: "minio",
       secret_access_key: "minio123"}

Files up to `multipart_threshold` are sent with a single `PutObject`. Larger
files are streamed from disk in `part_size` parts, so memory stays bounded.
The `last_modified` given by the writer is kept in the
`x-amz-meta-given-last-modified` metadata header and returned by `read/2`.

For Cloudflare R2 use `SiteMaps.Adapters.R2`.

## Options

* `:bucket` (`t:String.t/0`) - Required. Bucket name.

* `:prefix` (`t:String.t/0`) - Key prefix inside the bucket. The default value is `""`.

* `:region` (`t:String.t/0`) - Bucket region. Defaults to the ExAws configuration.

* `:endpoint` (`t:String.t/0`) - Base URL of an S3-compatible service, such as `"http://localhost:9000"`. Sets scheme, host and port of the ExAws configuration.

* `:access_key_id` (`t:String.t/0`) - Defaults to the ExAws configuration.

* `:secret_access_key` (`t:String.t/0`) - Defaults to the ExAws configuration.

* `:security_token` (`t:String.t/0`) - Session token for temporary credentials.

* `:acl` - Canned ACL such as `:public_read`. When `nil` no `x-amz-acl` header is sent, which is required by buckets with ACLs disabled.

* `:cache_control` (`t:String.t/0`) - Overrides the `cache_control` given by the sitemap configuration.

* `:storage_class` - Storage class, such as `:standard_ia`.

* `:virtual_host` (`t:boolean/0`) - Use virtual-hosted style (`bucket.host`) instead of path style. Defaults to the ExAws configuration.

* `:multipart_threshold` (`t:pos_integer/0`) - Files larger than this many bytes are uploaded in multiple parts. The default value is `8388608`.

* `:part_size` - Size in bytes of each multipart part, at least 5 MiB (5242880). The default value is `5242880`.

* `:ex_aws` (`t:keyword/0`) - Overrides merged last into the ExAws configuration, such as `http_client`. The default value is `[]`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
