# Ruby

Use Tigris with Ruby through the [AWS SDK for Ruby](https://aws.amazon.com/sdk-for-ruby/). The SDK works with Tigris by changing the endpoint configuration.

For the full SDK reference, see the [AWS Ruby SDK guide](/docs/sdks/s3/aws-ruby-sdk/.md).

## Prerequisites[​](#prerequisites "Direct link to Prerequisites")

* Ruby 3.0+
* A Tigris account — create one at [storage.new](https://storage.new)
* An access key from [console.storage.dev/createaccesskey](https://console.storage.dev/createaccesskey)

## Install[​](#install "Direct link to Install")

Add the AWS SDK to your `Gemfile`:

```
gem "aws-sdk-s3"
```

Then install:

```
bundle install
```

Or install directly:

```
gem install aws-sdk-s3
```

## Configure credentials[​](#configure-credentials "Direct link to Configure credentials")

Set your Tigris credentials as environment variables:

```
export AWS_ACCESS_KEY_ID="tid_your_access_key"

export AWS_SECRET_ACCESS_KEY="tsec_your_secret_key"
```

## Create a client[​](#create-a-client "Direct link to Create a client")

```
require "aws-sdk-s3"



s3 = Aws::S3::Client.new(

  region: "auto",

  endpoint: "https://t3.storage.dev",

  force_path_style: false,

)
```

The client reads credentials from the `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` environment variables automatically.

## Basic operations[​](#basic-operations "Direct link to Basic operations")

### List buckets[​](#list-buckets "Direct link to List buckets")

```
resp = s3.list_buckets



resp.buckets.each do |bucket|

  puts bucket.name

end
```

### Upload an object[​](#upload-an-object "Direct link to Upload an object")

```
s3.put_object(

  bucket: "my-bucket",

  key: "hello.txt",

  body: "Hello, World!",

)
```

### Download an object[​](#download-an-object "Direct link to Download an object")

```
resp = s3.get_object(

  bucket: "my-bucket",

  key: "hello.txt",

)



puts resp.body.read
```

### List objects[​](#list-objects "Direct link to List objects")

```
resp = s3.list_objects_v2(bucket: "my-bucket")



resp.contents.each do |object|

  puts "  #{object.key}  (#{object.size} bytes)"

end
```

### Generate a presigned URL[​](#generate-a-presigned-url "Direct link to Generate a presigned URL")

```
signer = Aws::S3::Presigner.new(client: s3)



url = signer.presigned_url(

  :get_object,

  bucket: "my-bucket",

  key: "hello.txt",

  expires_in: 3600,

)



puts url
```

## Next steps[​](#next-steps "Direct link to Next steps")

* [AWS Ruby SDK reference](/docs/sdks/s3/aws-ruby-sdk/.md) — presigned URLs, custom domains, and full configuration details
* [Snapshots and forks](/docs/buckets/snapshots-and-forks/.md) — Tigris snapshot and fork concepts
