Class S3Link
- Namespace
- Amazon.DynamoDBv2.DataModel
- Assembly
- AWSSDK.DynamoDBv2.dll
S3Link is an object that provides a connection to an S3 resource that can be stored in a DynamoDB field through DynamoDBContext
public class S3Link
- Inheritance
-
S3Link
- Inherited Members
Properties
BucketName
The name of the target Bucket for the managed resource
public string BucketName { get; set; }
Property Value
Key
The Key that S3Link stores and downloads a resource to and from
public string Key { get; set; }
Property Value
Region
The region the S3 resource is in
public string Region { get; set; }
Property Value
RegionAsEndpoint
Looks up RegionEndpoint based on region as a string
public RegionEndpoint RegionAsEndpoint { get; }
Property Value
- RegionEndpoint
Methods
Create(DynamoDBContext, string, string, RegionEndpoint)
Creates an S3Link that can be used to managed an S3 connection
public static S3Link Create(DynamoDBContext context, string bucket, string key, RegionEndpoint region)
Parameters
context
DynamoDBContextThe context that is handling the S3Link
bucket
stringThe bucket the S3Link should manage
key
stringThe key that S3Link should store and download from
region
RegionEndpointThe region of the S3 resource
Returns
- S3Link
A new S3Link object that can upload and download to the target bucket
DownloadToAsync(string, CancellationToken)
Downloads the file from the S3Link's specified bucket and key then saves it in the given path. Creates directories and the file if they do not already exist.
public Task DownloadToAsync(string downloadPath, CancellationToken cancellationToken = default)
Parameters
downloadPath
stringPath to save the file.
cancellationToken
CancellationTokenA cancellation token that can be used by other objects or threads to receive notice of cancellation.
Returns
- Task
An asynchronous task of the request
GetPreSignedURL(DateTime)
Provides a URL for accessing the S3 object managed by S3Link
public string GetPreSignedURL(DateTime expiration)
Parameters
expiration
DateTimeThe time the link should become invalid
Returns
- string
A URL directing to the S3 object
OpenStreamAsync(CancellationToken)
Opens a stream to object stored in Amazon S3.
public Task<Stream> OpenStreamAsync(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationTokenA cancellation token that can be used by other objects or threads to receive notice of cancellation.
Returns
UploadFromAsync(string, CancellationToken)
Uploads the specified file and stores it in the specified bucket with the provided key from construction.
public Task UploadFromAsync(string sourcePath, CancellationToken cancellationToken = default)
Parameters
sourcePath
stringPath of the file to be uploaded.
cancellationToken
CancellationTokenA cancellation token that can be used by other objects or threads to receive notice of cancellation.
Returns
- Task
An asynchronous task of the request
UploadStreamAsync(Stream, CancellationToken)
Uploads the stream and stores it in the specified bucket with the provided key from construction.
public Task UploadStreamAsync(Stream stream, CancellationToken cancellationToken = default)
Parameters
stream
StreamStream to be uploaded to Amazon S3.
cancellationToken
CancellationTokenA cancellation token that can be used by other objects or threads to receive notice of cancellation.
Returns
- Task
An asynchronous task of the request