Innovt Platform
Search Results for

    Show / Hide Table of Contents

    Class S3FileSystem

    Amazon S3 file system implementation.

    Inheritance
    object
    AwsBaseService
    S3FileSystem
    Implements
    IDisposable
    IFileSystem
    Inherited Members
    AwsBaseService.Configuration
    AwsBaseService.ExponentialBackoffInSeconds
    AwsBaseService.Logger
    AwsBaseService.Dispose()
    AwsBaseService.GetServiceRegionEndPoint()
    AwsBaseService.CreateService<T>()
    AwsBaseService.CreateDefaultRetryAsyncPolicy()
    AwsBaseService.CreateDefaultRetryPolicy()
    AwsBaseService.CreateRetryAsyncPolicy<T>()
    AwsBaseService.CreateRetryAsyncPolicy<T, T1>()
    AwsBaseService.CreateRetryAsyncPolicy<T, T1, T2>()
    AwsBaseService.CreateRetryAsyncPolicy<T, T1, T2, T3>()
    AwsBaseService.CreateRetryAsyncPolicy<T, T1, T2, T3, T4>()
    AwsBaseService.CreateCircuitBreaker<T, T1>()
    AwsBaseService.Dispose(bool)
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Innovt.Cloud.AWS.S3
    Assembly: Innovt.Cloud.AWS.S3.dll
    Syntax
    public class S3FileSystem : AwsBaseService, IDisposable, IFileSystem

    Constructors

    | Edit this page View Source

    S3FileSystem(ILogger, IAwsConfiguration)

    Initializes a new instance of the S3FileSystem class.

    Declaration
    public S3FileSystem(ILogger logger, IAwsConfiguration configuration)
    Parameters
    Type Name Description
    ILogger logger

    The logger.

    IAwsConfiguration configuration

    The AWS configuration.

    | Edit this page View Source

    S3FileSystem(ILogger, IAwsConfiguration, string)

    Initializes a new instance of the S3FileSystem class with a specific AWS region.

    Declaration
    public S3FileSystem(ILogger logger, IAwsConfiguration configuration, string region)
    Parameters
    Type Name Description
    ILogger logger

    The logger.

    IAwsConfiguration configuration

    The AWS configuration.

    string region

    The AWS region.

    Methods

    | Edit this page View Source

    CopyObject(string, string, string, string, string, string, CancellationToken)

    Asynchronously copies an object (file or folder) from the source bucket to the destination bucket.

    Declaration
    public Task<bool> CopyObject(string sourceBucket, string sourceKey, string destinationBucket, string destinationKey, string serverSideEncryptionMethod = null, string fileAcl = null, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    string sourceBucket

    The source bucket name.

    string sourceKey

    The source key of the object to copy.

    string destinationBucket

    The destination bucket name.

    string destinationKey

    The destination key for the copied object.

    string serverSideEncryptionMethod

    The server-side encryption method (optional).

    string fileAcl

    The file access control for the copied object (optional).

    CancellationToken cancellationToken

    A token to cancel the asynchronous operation (optional).

    Returns
    Type Description
    Task<bool>

    True if the object was successfully copied; otherwise, false.

    | Edit this page View Source

    DeleteObject(string, string)

    Synchronously deletes an object (file or folder) from the specified Amazon S3 bucket.

    Declaration
    public bool DeleteObject(string bucketName, string key)
    Parameters
    Type Name Description
    string bucketName

    The name of the S3 bucket.

    string key

    The key of the object to delete.

    Returns
    Type Description
    bool

    True if the object was successfully deleted; otherwise, false.

    | Edit this page View Source

    DeleteObjectAsync(string, string, CancellationToken)

    Asynchronously deletes an object (file or folder) from the specified Amazon S3 bucket.

    Declaration
    public Task<bool> DeleteObjectAsync(string bucketName, string key, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    string bucketName

    The name of the S3 bucket.

    string key

    The key of the object to delete.

    CancellationToken cancellationToken

    A token to cancel the asynchronous operation (optional).

    Returns
    Type Description
    Task<bool>

    True if the object was successfully deleted; otherwise, false.

    | Edit this page View Source

    DisposeServices()

    Disposes the S3 client instance.

    Declaration
    protected override void DisposeServices()
    Overrides
    AwsBaseService.DisposeServices()
    | Edit this page View Source

    Download(string, string, string)

    Downloads a file from an Amazon S3 bucket.

    Declaration
    public void Download(string bucketName, string fileName, string destination)
    Parameters
    Type Name Description
    string bucketName

    The name of the S3 bucket.

    string fileName

    The name of the file to download.

    string destination

    The local file path to save the downloaded file.

    | Edit this page View Source

    DownloadStream(string)

    Downloads a file from an Amazon S3 bucket as a stream using the provided URL.

    Declaration
    public Stream DownloadStream(string url)
    Parameters
    Type Name Description
    string url

    The URL of the file to download from Amazon S3.

    Returns
    Type Description
    Stream

    A stream containing the downloaded file's content.

    | Edit this page View Source

    DownloadStream(string, string)

    Downloads a file from an Amazon S3 bucket as a stream.

    Declaration
    public Stream DownloadStream(string bucketName, string fileName)
    Parameters
    Type Name Description
    string bucketName

    The name of the S3 bucket.

    string fileName

    The name of the file to download.

    Returns
    Type Description
    Stream

    A stream containing the downloaded file's content.

    | Edit this page View Source

    DownloadStreamAsync(string, string, CancellationToken)

    Asynchronously downloads a file from an Amazon S3 bucket as a stream.

    Declaration
    public Task<Stream> DownloadStreamAsync(string bucketName, string fileName, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    string bucketName

    The name of the S3 bucket.

    string fileName

    The name of the file to download.

    CancellationToken cancellationToken

    A token to cancel the asynchronous operation (optional).

    Returns
    Type Description
    Task<Stream>

    A stream containing the downloaded file's content.

    | Edit this page View Source

    DownloadStreamAsync(string, CancellationToken)

    Asynchronously downloads a file from an Amazon S3 bucket as a stream using the provided URL.

    Declaration
    public Task<Stream> DownloadStreamAsync(string url, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    string url

    The URL of the file to download from Amazon S3.

    CancellationToken cancellationToken

    A token to cancel the asynchronous operation (optional).

    Returns
    Type Description
    Task<Stream>

    A stream containing the downloaded file's content.

    | Edit this page View Source

    ExtractBucketFromGetUrl(string)

    Extracts bucket name and file key from the S3 bucket URL.

    Declaration
    public (string bucket, string fileKey) ExtractBucketFromGetUrl(string bucketUrl)
    Parameters
    Type Name Description
    string bucketUrl

    The S3 bucket URL.

    Returns
    Type Description
    (string bucket, string fileKey)

    A tuple containing the bucket name and the file key.

    | Edit this page View Source

    FileExistsAsync(string, string, CancellationToken)

    Asynchronously checks if a file exists in the specified Amazon S3 bucket.

    Declaration
    public Task<bool> FileExistsAsync(string bucketName, string key, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    string bucketName

    The name of the S3 bucket.

    string key

    The key representing the file in the S3 bucket.

    CancellationToken cancellationToken

    A token to cancel the asynchronous operation (optional).

    Returns
    Type Description
    Task<bool>

    True if the file exists; otherwise, false.

    | Edit this page View Source

    FolderExists(string, string)

    Synchronously checks if a folder exists in the specified Amazon S3 bucket.

    Declaration
    public bool FolderExists(string bucketName, string key)
    Parameters
    Type Name Description
    string bucketName

    The name of the S3 bucket.

    string key

    The key representing the folder in the S3 bucket.

    Returns
    Type Description
    bool

    True if the folder exists; otherwise, false.

    | Edit this page View Source

    FolderExistsAsync(string, string, CancellationToken)

    Asynchronously checks if a folder exists in the specified Amazon S3 bucket.

    Declaration
    public Task<bool> FolderExistsAsync(string bucketName, string key, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    string bucketName

    The name of the S3 bucket.

    string key

    The key representing the folder in the S3 bucket.

    CancellationToken cancellationToken

    A token to cancel the asynchronous operation (optional).

    Returns
    Type Description
    Task<bool>

    True if the folder exists; otherwise, false.

    | Edit this page View Source

    GeneratePreSignedUrl(string, string, DateTime, IDictionary<string, object>)

    Generates a pre-signed URL for accessing an object in the S3 bucket.

    Declaration
    public string GeneratePreSignedUrl(string bucketName, string key, DateTime expiration, IDictionary<string, object> additionalProperties)
    Parameters
    Type Name Description
    string bucketName

    The name of the S3 bucket.

    string key

    The key of the object in the S3 bucket.

    DateTime expiration

    The expiration date and time for the pre-signed URL.

    IDictionary<string, object> additionalProperties

    Additional properties for the pre-signed URL (optional).

    Returns
    Type Description
    string

    The pre-signed URL for accessing the object.

    | Edit this page View Source

    GetObjectContentAsync(string, string, Encoding, CancellationToken)

    Gets the content of the object from the specified URL asynchronously.

    Declaration
    public Task<string> GetObjectContentAsync(string bucketName, string key, Encoding encoding, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    string bucketName

    The Bucket name.

    string key

    The file url

    Encoding encoding
    CancellationToken cancellationToken
    Returns
    Type Description
    Task<string>
    | Edit this page View Source

    GetObjectContentAsync(string, Encoding, CancellationToken)

    Asynchronously gets the content of an object from a specified URL with the given encoding.

    Declaration
    public Task<string> GetObjectContentAsync(string url, Encoding encoding, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    string url

    The URL of the object to retrieve.

    Encoding encoding

    The encoding to use for reading the object's content.

    CancellationToken cancellationToken

    A token to cancel the asynchronous operation (optional).

    Returns
    Type Description
    Task<string>

    The content of the object as a string.

    | Edit this page View Source

    GetObjectFromJsonAsync<T>(Uri, CancellationToken)

    When you need to get a content from Json file as an typed method.

    Declaration
    public Task<T> GetObjectFromJsonAsync<T>(Uri filePath, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    Uri filePath
    CancellationToken cancellationToken
    Returns
    Type Description
    Task<T>
    Type Parameters
    Name Description
    T
    | Edit this page View Source

    GetPreSignedUrl(string, string, DateTime)

    Gets a pre-signed URL for accessing an object in the S3 bucket.

    Declaration
    public string GetPreSignedUrl(string bucketName, string key, DateTime expires)
    Parameters
    Type Name Description
    string bucketName

    The name of the S3 bucket.

    string key

    The key of the object in the S3 bucket.

    DateTime expires

    The expiration date and time for the pre-signed URL.

    Returns
    Type Description
    string

    The pre-signed URL for accessing the object.

    | Edit this page View Source

    PutObject(string, Stream, string, string, string, string)

    Uploads a stream to an Amazon S3 bucket.

    Declaration
    public string PutObject(string bucketName, Stream stream, string fileName, string contentType = null, string serverSideEncryptionMethod = null, string fileAcl = null)
    Parameters
    Type Name Description
    string bucketName

    The name of the S3 bucket.

    Stream stream

    The stream to upload.

    string fileName

    The name to assign to the uploaded file.

    string contentType

    The content type of the file (optional).

    string serverSideEncryptionMethod

    The server-side encryption method (optional).

    string fileAcl

    The file access control list (optional).

    Returns
    Type Description
    string

    The key of the uploaded object in the S3 bucket.

    | Edit this page View Source

    PutObject(string, string, string, string, string)

    Uploads a file to an Amazon S3 bucket.

    Declaration
    public string PutObject(string bucketName, string filePath, string contentType = null, string serverSideEncryptionMethod = null, string fileAcl = null)
    Parameters
    Type Name Description
    string bucketName

    The name of the S3 bucket.

    string filePath

    The local file path of the file to upload.

    string contentType

    The content type of the file (optional).

    string serverSideEncryptionMethod

    The server-side encryption method (optional).

    string fileAcl

    The file access control list (optional).

    Returns
    Type Description
    string

    The key of the uploaded object in the S3 bucket.

    | Edit this page View Source

    PutObjectAsync(string, Stream, string, string, string, string, CancellationToken)

    Asynchronously uploads a stream to an Amazon S3 bucket.

    Declaration
    public Task<string> PutObjectAsync(string bucketName, Stream stream, string fileName, string contentType = null, string serverSideEncryptionMethod = null, string fileAcl = null, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    string bucketName

    The name of the S3 bucket.

    Stream stream

    The stream to upload.

    string fileName

    The name to assign to the uploaded file.

    string contentType

    The content type of the file (optional).

    string serverSideEncryptionMethod

    The server-side encryption method (optional).

    string fileAcl

    The file access control list (optional).

    CancellationToken cancellationToken

    A token to cancel the asynchronous operation (optional).

    Returns
    Type Description
    Task<string>

    The key of the uploaded object in the S3 bucket.

    | Edit this page View Source

    PutObjectAsync(string, string, string, string, string, CancellationToken)

    Asynchronously uploads a file to an Amazon S3 bucket.

    Declaration
    public Task<string> PutObjectAsync(string bucketName, string filePath, string contentType = null, string serverSideEncryptionMethod = null, string fileAcl = null, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    string bucketName

    The name of the S3 bucket.

    string filePath

    The local file path of the file to upload.

    string contentType

    The content type of the file (optional).

    string serverSideEncryptionMethod

    The server-side encryption method (optional).

    string fileAcl

    The file access control list (optional).

    CancellationToken cancellationToken

    A token to cancel the asynchronous operation (optional).

    Returns
    Type Description
    Task<string>

    The key of the uploaded object in the S3 bucket.

    | Edit this page View Source

    Upload(string, Stream, string, IList<KeyValuePair<string, string>>, string, string)

    Uploads a file to the specified Amazon S3 bucket from a stream.

    Declaration
    public string Upload(string bucketName, Stream stream, string fileName, IList<KeyValuePair<string, string>> metadata = null, string serverSideEncryptionMethod = null, string fileAcl = null)
    Parameters
    Type Name Description
    string bucketName

    The name of the S3 bucket.

    Stream stream

    The stream containing the file content to upload.

    string fileName

    The name of the file to upload.

    IList<KeyValuePair<string, string>> metadata

    Metadata key-value pairs for the uploaded file (optional).

    string serverSideEncryptionMethod

    The server-side encryption method (optional).

    string fileAcl

    The file access control for the uploaded file (optional).

    Returns
    Type Description
    string

    The URL of the uploaded file.

    | Edit this page View Source

    Upload(string, string, IList<KeyValuePair<string, string>>, string, string)

    Uploads a file to the specified Amazon S3 bucket from a local file path.

    Declaration
    public string Upload(string bucketName, string filePath, IList<KeyValuePair<string, string>> metadata = null, string serverSideEncryptionMethod = null, string fileAcl = null)
    Parameters
    Type Name Description
    string bucketName

    The name of the S3 bucket.

    string filePath

    The local file path to upload.

    IList<KeyValuePair<string, string>> metadata

    Metadata key-value pairs for the uploaded file (optional).

    string serverSideEncryptionMethod

    The server-side encryption method (optional).

    string fileAcl

    The file access control for the uploaded file (optional).

    Returns
    Type Description
    string

    The URL of the uploaded file.

    | Edit this page View Source

    UploadAsJsonAsync<T>(string, T, string, IList<KeyValuePair<string, string>>, string, string, CancellationToken)

    Asynchronously uploads an object serialized as JSON to the specified Amazon S3 bucket.

    Declaration
    public Task<string> UploadAsJsonAsync<T>(string bucketName, T obj, string fileName, IList<KeyValuePair<string, string>> metadata = null, string serverSideEncryptionMethod = null, string fileAcl = null, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    string bucketName

    The name of the S3 bucket.

    T obj

    The object to serialize and upload.

    string fileName

    The name of the file to use for the uploaded object.

    IList<KeyValuePair<string, string>> metadata

    Metadata key-value pairs for the uploaded object (optional).

    string serverSideEncryptionMethod

    The server-side encryption method (optional).

    string fileAcl

    The file access control for the uploaded object (optional).

    CancellationToken cancellationToken

    A token to cancel the asynchronous operation (optional).

    Returns
    Type Description
    Task<string>

    The URL of the uploaded object.

    Type Parameters
    Name Description
    T

    The type of the object to serialize.

    | Edit this page View Source

    UploadAsync(string, Stream, string, IList<KeyValuePair<string, string>>, string, string, CancellationToken)

    Asynchronously uploads a file to the specified Amazon S3 bucket from a stream.

    Declaration
    public Task<string> UploadAsync(string bucketName, Stream stream, string fileName, IList<KeyValuePair<string, string>> metadata = null, string serverSideEncryptionMethod = null, string fileAcl = null, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    string bucketName

    The name of the S3 bucket.

    Stream stream

    The stream containing the file content to upload.

    string fileName

    The name of the file to upload.

    IList<KeyValuePair<string, string>> metadata

    Metadata key-value pairs for the uploaded file (optional).

    string serverSideEncryptionMethod

    The server-side encryption method (optional).

    string fileAcl

    The file access control for the uploaded file (optional).

    CancellationToken cancellationToken

    A token to cancel the asynchronous operation (optional).

    Returns
    Type Description
    Task<string>

    The URL of the uploaded file.

    | Edit this page View Source

    UploadAsync(string, string, IList<KeyValuePair<string, string>>, string, string, CancellationToken)

    Asynchronously uploads an object from a local file path to the specified Amazon S3 bucket.

    Declaration
    public Task<string> UploadAsync(string bucketName, string filePath, IList<KeyValuePair<string, string>> metadata = null, string serverSideEncryptionMethod = null, string fileAcl = null, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    string bucketName

    The name of the S3 bucket.

    string filePath

    The local file path to upload.

    IList<KeyValuePair<string, string>> metadata

    Metadata key-value pairs for the uploaded object (optional).

    string serverSideEncryptionMethod

    The server-side encryption method (optional).

    string fileAcl

    The file access control for the uploaded object (optional).

    CancellationToken cancellationToken

    A token to cancel the asynchronous operation (optional).

    Returns
    Type Description
    Task<string>

    The URL of the uploaded object.

    | Edit this page View Source

    UploadDirectoryAsync(string, string, string, string, CancellationToken)

    Asynchronously uploads a directory to the specified Amazon S3 bucket.

    Declaration
    public Task UploadDirectoryAsync(string bucketName, string directory, string serverSideEncryptionMethod = null, string fileAcl = null, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    string bucketName

    The name of the S3 bucket.

    string directory

    The path of the local directory to upload.

    string serverSideEncryptionMethod

    The server-side encryption method (optional).

    string fileAcl

    The file access control for the uploaded files (optional).

    CancellationToken cancellationToken

    A token to cancel the asynchronous operation (optional).

    Returns
    Type Description
    Task

    A task representing the asynchronous operation.

    Implements

    IDisposable
    IFileSystem

    Extension Methods

    Extensions.IsNull(object)
    Extensions.ToStringOrDefault(object)
    SimpleMapper.MapTo<T1>(object)
    • Edit this page
    • View Source
    In this article
    Back to top Generated by DocFX