AWS S3 Storage - robinrodricks/FluentStorage GitHub Wiki
In order to use AWS S3 or S3-compatible storage you need to reference the FluentStorage.AWS package first. The provider wraps around the standard AWS SDK.
You can use the AwsS3Storage factory class to connect to AWS S3 storage.
IStore store = AwsS3Storage.FromCredentials(
accessKeyId, secretAccessKey, sessionToken, bucketName);To create with a connection string, first reference the module:
AwsS3Storage.Use();Then construct using the following format:
IStore store = StorageFactory.FromConnectionString("aws.s3://keyId=...;key=...;bucket=...;region=...");where:
- keyId is (optional) access key ID.
- key is (optional) secret access key.
- bucket is bucket name.
-
region is the AWS account region (such as
us-east-1). - serviceUrl is the optional URL of the storage provider (for example for DigitalOcean).
If keyId and key are omitted, the AWS SDK's default approach to credential resolution will be used. For example: if running in Lambda, it will assume the Lambda execution role; if there are credentials configured in ~/.aws, it will use those; etc. See AWS SDK Documentation for more details.
Use our simple polycloud API to perform file and object manipulation operations.
If you already have credentials in the local ~/.aws/credentials generated by AWS CLI, you can also use them to connect to a bucket with FluentStorage. Credentials file example:
[default]
aws_access_key_id = ASIAV44FYRYLSBYIPG67
aws_secret_access_key = zhuh8nSUAR0pR5jbi4vhUym95JsC7ay3iiE2v9Jq
aws_session_token = FQoGZXIvY...
[anotherProfile]
aws_access_key_id = ASIAXEKXYP2H7MRN45FD
aws_secret_access_key = 8i6jnOOurRtTiK4CWN+uUD115SYS8++ZuQjO/LtW
aws_session_token = FQoGZXI...
...To connect using say anotherProfile credentials, construct the instance by:
IStore bs = AwsS3Storage.FromConfigFile(
"anotherProfile",
"bucketName",
"region");AwsCliCredentials class contains credentials file parrsing logic and some utility methods you mind find useful, for instance enumerating available profiles and so on.
- Remote directory recursion occurs on S3 cloud rather than locally (
ListFolderAsyncAPI). -
ListOptionshas aPageSizeparameter which can be used to control the internal paging size used for remote recursion.
Call the IStore.GetClient() method to return the native SDK client and perform any native operations.