Skip to content

Foundatio.AWS

Foundatio provides AWS implementations for file storage and queuing using Amazon S3 and Amazon SQS. View source on GitHub →

Overview

ImplementationInterfacePackage
S3FileStorageIFileStorageFoundatio.AWS
SQSQueue<T>IQueue<T>Foundatio.AWS

Installation

bash
dotnet add package Foundatio.AWS

S3FileStorage

Store files in Amazon S3 with full support for buckets, prefixes, and metadata.

csharp
using Foundatio.Storage;

var storage = new S3FileStorage(o =>
{
    o.ConnectionString = connectionString;
    // Or: o.Bucket = "my-files"; o.Region = RegionEndpoint.USEast1;
});

await storage.SaveFileAsync("documents/report.pdf", pdfStream);

Configuration

OptionTypeRequiredDescription
BucketstringS3 bucket name
RegionRegionEndpointAWS region
ConnectionStringstringParses all settings
CredentialsAWSCredentialsAWS credentials
ServiceUrlstringCustom endpoint (LocalStack)

For additional options, see S3FileStorageOptions source.

SQSQueue

AWS SQS queue implementation.

csharp
using Foundatio.Queues;

var queue = new SQSQueue<WorkItem>(o =>
{
    o.ConnectionString = connectionString;
    o.Name = "work-items";
});

await queue.EnqueueAsync(new WorkItem { Data = "Hello" });
var entry = await queue.DequeueAsync();

Configuration

OptionTypeRequiredDefaultDescription
NamestringQueue name
ConnectionStringstringConnection string
RegionRegionEndpointAWS region
CanCreateQueuebooltrueAuto-create queue
SupportDeadLetterbooltrueEnable DLQ support
ReadQueueTimeoutTimeSpan20sLong polling timeout

For additional options, see SQSQueueOptions source.

Next Steps

Released under the Apache 2.0 License.