# Use an AWS SDK

Point the AWS SDK for Python or JavaScript at the S3 endpoint and upload and download objects.

The AWS SDKs work with the endpoint, including their default chunk-signed and checksummed uploads. Replace _EWS1EXAMPLEEXAMPLE00_ and _&lt;secret&gt;_ with your
access key, _example-uploads_ with your bucket's name and `https://s3.<domain>` with the endpoint.
The bucket's **Overview** shows the same snippets under **Connect**.

## Prerequisites

- An access key (see [Create an access key](create-an-access-key.md)) whose IAM user may read and
  write the bucket.

## Python (boto3)

```python
import boto3
from botocore.config import Config

s3 = boto3.client(
    "s3",
    endpoint_url="https://s3.<domain>",
    aws_access_key_id="EWS1EXAMPLEEXAMPLE00",
    aws_secret_access_key="<secret>",
    region_name="de1",
    config=Config(s3={"addressing_style": "virtual"}),
)

s3.upload_file("report.pdf", "example-uploads", "report.pdf")
s3.download_file("example-uploads", "report.pdf", "copy.pdf")
```

## JavaScript (`@aws-sdk/client-s3`)

```js
import { GetObjectCommand, PutObjectCommand, S3Client } from '@aws-sdk/client-s3';

const s3 = new S3Client({
  endpoint: 'https://s3.<domain>',
  region: 'de1',
  forcePathStyle: false,
  credentials: { accessKeyId: 'EWS1EXAMPLEEXAMPLE00', secretAccessKey: '<secret>' },
});

await s3.send(new PutObjectCommand({ Bucket: 'example-uploads', Key: 'hello.txt', Body: 'hello' }));
const res = await s3.send(new GetObjectCommand({ Bucket: 'example-uploads', Key: 'hello.txt' }));
```

Both SDKs then address the bucket virtual-hosted style, the bucket as the first part of the host
name: requests go to `https://example-uploads.s3.<domain>/<key>`, the bucket's **Address**. The
endpoint setting is the service's; the SDK adds the bucket (`addressing_style "virtual"` in
boto3, `forcePathStyle: false` in JavaScript).

## Result

The SDK reads and writes the bucket as the key's IAM user. For temporary credentials, also set the
session token (see [Create temporary credentials](create-temporary-credentials.md)).

## Related

- [S3 compatibility](s3-compatibility.md)
- [Use the AWS CLI](use-the-aws-cli.md)
