Interface IFileSystem
Interface for File System
Namespace: Innovt.Cloud.File
Assembly: Innovt.Cloud.dll
Syntax
public interface IFileSystem
Methods
| Edit this page View SourceCopyObject(string, string, string, string, string, string, CancellationToken)
Copy a file from one bucket to another
Declaration
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 | |
string | sourceKey | |
string | destinationBucket | |
string | destinationKey | |
string | serverSideEncryptionMethod | |
string | fileAcl | |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<bool> |
DeleteObject(string, string)
Deletes an object from the specified bucket.
Declaration
bool DeleteObject(string bucketName, string key)
Parameters
Type | Name | Description |
---|---|---|
string | bucketName | |
string | key |
Returns
Type | Description |
---|---|
bool |
DeleteObjectAsync(string, string, CancellationToken)
Deletes an object from the specified bucket.
Declaration
Task<bool> DeleteObjectAsync(string bucketName, string key, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | bucketName | |
string | key | |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<bool> |
Download(string, string, string)
Downloads a file from the specified bucket and saves it to the destination path.
Declaration
void Download(string bucketName, string fileName, string destination)
Parameters
Type | Name | Description |
---|---|---|
string | bucketName | |
string | fileName | |
string | destination |
DownloadStream(string)
Downloads a file from the provided URL and returns the stream.
Declaration
Stream DownloadStream(string url)
Parameters
Type | Name | Description |
---|---|---|
string | url |
Returns
Type | Description |
---|---|
Stream |
DownloadStream(string, string)
Downloads a file from the specified bucket and file name synchronously and returns the stream.
Declaration
Stream DownloadStream(string bucketName, string fileName)
Parameters
Type | Name | Description |
---|---|---|
string | bucketName | The name of the bucket. |
string | fileName | The name of the file to download. |
Returns
Type | Description |
---|---|
Stream | The stream of the downloaded file. |
DownloadStreamAsync(string, string, CancellationToken)
Downloads a file from the specified bucket and file name asynchronously and returns the stream.
Declaration
Task<Stream> DownloadStreamAsync(string bucketName, string fileName, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | bucketName | The name of the bucket. |
string | fileName | The name of the file to download. |
CancellationToken | cancellationToken | The cancellation token to cancel the asynchronous operation. |
Returns
Type | Description |
---|---|
Task<Stream> | The stream of the downloaded file. |
DownloadStreamAsync(string, CancellationToken)
Downloads a file from the provided URL asynchronously and returns the stream.
Declaration
Task<Stream> DownloadStreamAsync(string url, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | url | The URL of the file to download. |
CancellationToken | cancellationToken | The cancellation token to cancel the asynchronous operation. |
Returns
Type | Description |
---|---|
Task<Stream> | The stream of the downloaded file. |
ExtractBucketFromGetUrl(string)
Extracts the bucket name and file key from the provided URL.
Declaration
(string bucket, string fileKey) ExtractBucketFromGetUrl(string bucketUrl)
Parameters
Type | Name | Description |
---|---|---|
string | bucketUrl | The URL containing bucket information. |
Returns
Type | Description |
---|---|
(string bucket, string fileKey) | A tuple containing the bucket name and file key. |
FileExistsAsync(string, string, CancellationToken)
Checks if a file exists in the specified bucket asynchronously.
Declaration
Task<bool> FileExistsAsync(string bucketName, string key, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | bucketName | The name of the bucket. |
string | key | The key of the file. |
CancellationToken | cancellationToken | The cancellation token to cancel the asynchronous operation. |
Returns
Type | Description |
---|---|
Task<bool> | True if the file exists; otherwise, false. |
FolderExists(string, string)
Checks if a folder exists in the specified bucket.
Declaration
bool FolderExists(string bucketName, string key)
Parameters
Type | Name | Description |
---|---|---|
string | bucketName | The name of the bucket. |
string | key | The key of the folder. |
Returns
Type | Description |
---|---|
bool | True if the folder exists; otherwise, false. |
FolderExistsAsync(string, string, CancellationToken)
Checks if a folder exists in the specified bucket asynchronously.
Declaration
Task<bool> FolderExistsAsync(string bucketName, string key, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | bucketName | The name of the bucket. |
string | key | The key of the folder. |
CancellationToken | cancellationToken | The cancellation token to cancel the asynchronous operation. |
Returns
Type | Description |
---|---|
Task<bool> | True if the folder exists; otherwise, false. |
GeneratePreSignedUrl(string, string, DateTime, IDictionary<string, object>)
Generates a pre-signed URL for accessing the object in the specified bucket.
Declaration
string GeneratePreSignedUrl(string bucketName, string key, DateTime expiration, IDictionary<string, object> additionalProperties)
Parameters
Type | Name | Description |
---|---|---|
string | bucketName | The name of the bucket. |
string | key | The key of the object. |
DateTime | expiration | The expiration date and time for the pre-signed URL. |
IDictionary<string, object> | additionalProperties | Additional properties for customizing the URL generation. |
Returns
Type | Description |
---|---|
string | The pre-signed URL for accessing the object. |
GetObjectContentAsync(string, string, Encoding, CancellationToken)
Gets the content of the object from the specified URL asynchronously.
Declaration
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> |
GetObjectContentAsync(string, Encoding, CancellationToken)
Gets the content of the object from the specified URL asynchronously.
Declaration
Task<string> GetObjectContentAsync(string url, Encoding encoding, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | url | The URL of the object. |
Encoding | encoding | The encoding to use for reading the content. |
CancellationToken | cancellationToken | The cancellation token to cancel the asynchronous operation. |
Returns
Type | Description |
---|---|
Task<string> | The content of the object as a string. |
GetObjectFromJsonAsync<T>(Uri, CancellationToken)
Deserializes a JSON object from the content of a file specified by a URI.
Declaration
Task<T> GetObjectFromJsonAsync<T>(Uri filePath, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
Uri | filePath | The URI pointing to the JSON file. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<T> | The deserialized object of type |
Type Parameters
Name | Description |
---|---|
T | The type of the object to deserialize to. |
GetPreSignedUrl(string, string, DateTime)
Gets a pre-signed URL for accessing the object in the specified bucket.
Declaration
string GetPreSignedUrl(string bucketName, string key, DateTime expires)
Parameters
Type | Name | Description |
---|---|---|
string | bucketName | The name of the bucket. |
string | key | The key of the object. |
DateTime | expires | The expiration date and time for the pre-signed URL. |
Returns
Type | Description |
---|---|
string | The pre-signed URL for accessing the object. |
PutObject(string, Stream, string, string, string, string)
Uploads a file from a stream to the specified bucket.
Declaration
string PutObject(string bucketName, Stream stream, string fileName, string contentType = null, string serverSideEncryptionMethod = null, string fileAcl = null)
Parameters
Type | Name | Description |
---|---|---|
string | bucketName | |
Stream | stream | |
string | fileName | |
string | contentType | |
string | serverSideEncryptionMethod | |
string | fileAcl |
Returns
Type | Description |
---|---|
string |
PutObject(string, string, string, string, string)
Uploads a file from a local file path to the specified bucket.
Declaration
string PutObject(string bucketName, string filePath, string contentType = null, string serverSideEncryptionMethod = null, string fileAcl = null)
Parameters
Type | Name | Description |
---|---|---|
string | bucketName | |
string | filePath | |
string | contentType | |
string | serverSideEncryptionMethod | |
string | fileAcl |
Returns
Type | Description |
---|---|
string |
PutObjectAsync(string, Stream, string, string, string, string, CancellationToken)
Uploads an object from a stream to the specified bucket asynchronously.
Declaration
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 bucket. |
Stream | stream | The stream containing the object to upload. |
string | fileName | The name of the file to upload. |
string | contentType | The content type of the object. |
string | serverSideEncryptionMethod | The server-side encryption method to use. |
string | fileAcl | The access control for the object. |
CancellationToken | cancellationToken | The cancellation token to cancel the asynchronous operation. |
Returns
Type | Description |
---|---|
Task<string> | The unique identifier of the uploaded object. |
PutObjectAsync(string, string, string, string, string, CancellationToken)
Uploads an object from a local file to the specified bucket asynchronously.
Declaration
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 bucket. |
string | filePath | The local file path of the object to upload. |
string | contentType | The content type of the object. |
string | serverSideEncryptionMethod | The server-side encryption method to use. |
string | fileAcl | The access control for the object. |
CancellationToken | cancellationToken | The cancellation token to cancel the asynchronous operation. |
Returns
Type | Description |
---|---|
Task<string> | The unique identifier of the uploaded object. |
Upload(string, Stream, string, IList<KeyValuePair<string, string>>, string, string)
Uploads an object from a stream to the specified bucket synchronously.
Declaration
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 bucket. |
Stream | stream | The stream containing the object to upload. |
string | fileName | The name of the file to upload. |
IList<KeyValuePair<string, string>> | metadata | Metadata for the object. |
string | serverSideEncryptionMethod | The server-side encryption method to use. |
string | fileAcl | The access control for the object. |
Returns
Type | Description |
---|---|
string | The unique identifier of the uploaded object. |
Upload(string, string, IList<KeyValuePair<string, string>>, string, string)
Uploads an object from a local file to the specified bucket synchronously.
Declaration
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 bucket. |
string | filePath | The local file path of the object to upload. |
IList<KeyValuePair<string, string>> | metadata | Metadata for the object. |
string | serverSideEncryptionMethod | The server-side encryption method to use. |
string | fileAcl | The access control for the object. |
Returns
Type | Description |
---|---|
string | The unique identifier of the uploaded object. |
UploadAsJsonAsync<T>(string, T, string, IList<KeyValuePair<string, string>>, string, string, CancellationToken)
Uploads an object as JSON to the specified bucket.
Declaration
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 | |
T | obj | |
string | fileName | |
IList<KeyValuePair<string, string>> | metadata | |
string | serverSideEncryptionMethod | |
string | fileAcl | |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<string> |
Type Parameters
Name | Description |
---|---|
T |
UploadAsync(string, Stream, string, IList<KeyValuePair<string, string>>, string, string, CancellationToken)
Uploads an object from a stream to the specified bucket asynchronously.
Declaration
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 bucket. |
Stream | stream | The stream containing the object to upload. |
string | fileName | The name of the file to upload. |
IList<KeyValuePair<string, string>> | metadata | Metadata for the object. |
string | serverSideEncryptionMethod | The server-side encryption method to use. |
string | fileAcl | The access control for the object. |
CancellationToken | cancellationToken | The cancellation token to cancel the asynchronous operation. |
Returns
Type | Description |
---|---|
Task<string> | The unique identifier of the uploaded object. |
UploadAsync(string, string, IList<KeyValuePair<string, string>>, string, string, CancellationToken)
Uploads an object from a local file to the specified bucket asynchronously.
Declaration
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 bucket. |
string | filePath | The local file path of the object to upload. |
IList<KeyValuePair<string, string>> | metadata | Metadata for the object. |
string | serverSideEncryptionMethod | The server-side encryption method to use. |
string | fileAcl | The access control for the object. |
CancellationToken | cancellationToken | The cancellation token to cancel the asynchronous operation. |
Returns
Type | Description |
---|---|
Task<string> | The unique identifier of the uploaded object. |
UploadDirectoryAsync(string, string, string, string, CancellationToken)
Uploads all files in a directory to the specified bucket.
Declaration
Task UploadDirectoryAsync(string bucketName, string directory, string serverSideEncryptionMethod = null, string fileAcl = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | bucketName | |
string | directory | |
string | serverSideEncryptionMethod | |
string | fileAcl | |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task |