# AWS .Net SDK

<!-- -->

This guide assumes that you have followed the steps in the [Getting Started](/docs/get-started/.md) guide, and have the access keys available.

You may continue to use the AWS .Net SDK as you normally would, but with the endpoint set to Tigris. If you are using Tigris outside of Fly, use the endpoint <https://t3.storage.dev>. If you are using Tigris from within Fly, use the endpoint <https://fly.storage.tigris.dev>.

This example uses the [AWS .Net SDK v3](https://www.nuget.org/packages/AWSSDK.S3) and reads the default credentials file or the environment variables `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`.

Install the SDK from nuget:

```
dotnet add package AWSSDK.S3
dotnet add package AWSSDK.SecurityToken
dotnet add package AWSSDK.SSO
dotnet add package AWSSDK.SSOOIDC
```

Then you can use the SDK as you normally would, but with the endpoint set to Tigris. If you are using Tigris outside of Fly, use the endpoint <https://t3.storage.dev>. If you are using Tigris from within Fly, use the endpoint <https://fly.storage.tigris.dev>.

<!-- -->

```
using Amazon.Runtime;
using Amazon.Runtime.CredentialManagement;
using Amazon.S3;
using Amazon.S3.Model;

IAmazonS3 s3Client = new AmazonS3Client(
    new AmazonS3Config { ForcePathStyle = false, ServiceURL = "https://t3.storage.dev" }
);

var bucketName = "tigris-example";

// List buckets
var listResponse = await s3Client.ListBucketsAsync();

Console.WriteLine("Buckets:");
foreach (var s3Bucket in listResponse.Buckets)
{
    Console.WriteLine("* {0}", s3Bucket.BucketName);
}

// PutObject
var putObjectRequest = new PutObjectRequest
{
    BucketName = bucketName,
    Key = "test_object_key",
    ContentBody = "Test object data",
    UseChunkEncoding = false,
};

var responsePut = await s3Client.PutObjectAsync(putObjectRequest);

Console.WriteLine($"PUT {responsePut.ETag}");

// GetObject
var getRequest = new GetObjectRequest { BucketName = bucketName, Key = "test_object_key" };

using (var responseGet = await s3Client.GetObjectAsync(getRequest))
{
    using (var reader = new StreamReader(responseGet.ResponseStream))
    {
        var content = reader.ReadToEnd();
        Console.WriteLine($"GET '{content}'");
    }
}

// List objects
var request = new ListObjectsV2Request { BucketName = bucketName };

var response = await s3Client.ListObjectsV2Async(request);

foreach (var s3Object in response.S3Objects)
{
    Console.WriteLine("{0}", s3Object.Key);
}
```

note

Tigris currently does not support chunk encoding. You must set `UseChunkEncoding` to `false` in the `PutObjectRequest`.

```
#r "nuget: AWSSDK.S3, 3.7.414.1"

using Amazon.Runtime;
using Amazon.Runtime.CredentialManagement;
using Amazon.S3;
using Amazon.S3.Model;

IAmazonS3 s3Client = new AmazonS3Client(
    new AmazonS3Config { ForcePathStyle = false,  ServiceURL = "https://t3.storage.dev" }
);

var bucketName = "tigris-example";

// PutObject
var putObjectRequest = new PutObjectRequest
{
    BucketName = bucketName,
    Key = "test_object_key",
    ContentBody = "Test object data",
    UseChunkEncoding = false, // <- Required for Tigris
};

var responsePut = await s3Client.PutObjectAsync(putObjectRequest);

Console.WriteLine($"PUT {responsePut.ETag}");
```

## Pre-signed URLs[​](#pre-signed-urls "Direct link to Pre-signed URLs")

Using Tigris with the .NET SDK is easy with one small change. The .Net SDK defaults to using v2 signatures, Tigris only supports v4 signatures. In order to use pre-signed URLs, you must set `UseSignatureV4` to `true` in the global `AWSConfigsS3` object in the Amazon namespace.

```
using Amazon;

AWSConfigsS3.UseSignatureVersion4 = true;
```

<!-- -->

```
#r "nuget: AWSSDK.S3, 3.7.414.1"

using Amazon;
using Amazon.S3;
using Amazon.S3.Model;

AWSConfigsS3.UseSignatureVersion4 = true;

IAmazonS3 s3Client = new AmazonS3Client(
    new AmazonS3Config { ForcePathStyle = false, ServiceURL = "https://t3.storage.dev" }
);

var bucketName = "tigris-example";
string objectName = "bar.txt";

// get object
GetPreSignedUrlRequest preSignedUrlRequest = new GetPreSignedUrlRequest
{
    BucketName = bucketName,
    Key = objectName,
    Expires = DateTime.UtcNow.AddHours(1),
    Verb = HttpVerb.GET,
};

string preSignedUrl = s3Client.GetPreSignedURL(preSignedUrlRequest);
Console.WriteLine($"Presigned GET URL: {preSignedUrl}");
```

### Presigned URLs with custom domains[​](#presigned-urls-with-custom-domains "Direct link to Presigned URLs with custom domains")

You can also use a [presigned URL with a custom domain](/docs/objects/presigned/.md#presigned-url-with-custom-domain) by replacing the Tigris domain name with your custom domain name:

```
string brandedURL = presignedUrl.Replace("t3.storage.dev", "your-domain.example.com");
Console.WriteLine($"Presigned URL for GET (custom domain): {brandedURL}");
```
