Movatterモバイル変換


[0]ホーム

URL:


Close Sidebar

.NET Client API Reference

Initialize MinIO client object

MinIO

IMinioClientminioClient=newMinioClient().WithEndpoint("play.min.io").WithCredentials("Q3AM3UQ867SPQQA43P2F","zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG").WithSSL().Build();

AWS S3

IIMinioClientminioClient=newMinioClient().WithEndpoint("s3.amazonaws.com").WithCredentials("YOUR-ACCESSKEYID","YOUR-SECRETACCESSKEY").WithSSL().Build();
Bucket operationsObject operationsPresigned operationsBucket Policy Operations
makeBucketgetObjectpresignedGetObjectgetBucketPolicy
listBucketsputObjectpresignedPutObjectsetBucketPolicy
bucketExistscopyObjectpresignedPostPolicysetBucketNotification
removeBucketstatObjectgetBucketNotification
listObjectsremoveObjectremoveAllBucketNotification
listIncompleteUploadsremoveObjects
listenBucketNotificationsselectObjectContent
setVersioningsetLegalHold
getVersioninggetLegalHold
setBucketEncryptionsetObjectTags
getBucketEncryptiongetObjectTags
removeBucketEncryptionremoveObjectTags
setBucketTagssetObjectRetention
getBucketTagsgetObjectRetention
removeBucketTagsclearObjectRetention
setObjectLockremoveIncompleteUpload
getObjectLock
removeObjectLock
setBucketLifecycle
getBucketLifecycle
removeBucketLifecycle
setBucketReplication
getBucketReplication
removeBucketReplication

1. Constructors

public MinioClient(string endpoint, string accessKey = "", string secretKey = "", string region = "", string sessionToken="")
Creates MinIO client object with given endpoint.AccessKey, secretKey, region and sessionToken are optional parameters, and can be omitted for anonymous access.
The client object uses Http access by default. To use Https, chain method WithSSL() to client object to use secure transfer protocol

Parameters

ParamTypeDescription
endpointstringendPoint is an URL, domain name, IPv4 address or IPv6 address.Valid endpoints are listed below:
s3.amazonaws.com
play.min.io
localhost
play.min.io
accessKeystringaccessKey is like user-id that uniquely identifies your account.This field is optional and can be omitted for anonymous access.
secretKeystringsecretKey is the password to your account.This field is optional and can be omitted for anonymous access.
regionstringregion to which calls should be made.This field is optional and can be omitted.
sessionTokenstringsessionToken needs to be set if temporary access credentials are used
Secure Access (TLS)
Chain .WithSSL() or WithSSL(true) to MinIO Client object to use https.
Chain .WithSSL(false) or nothing to Client object to use http.
Proxy
Chain .WithProxy(proxyObject) to MinIO Client object to use proxy
public MinioClient()
Creates MinIO client. This client gives an empty object that can be used with Chaining to populate only the member variables we need.
The next important step is to connect to an endpoint. You can chain one of the overloaded method WithEndpoint() to client object to connect.
This client object also uses Http access by default. To use Https, chain method WithSSL() or WithSSL(true) to client object to use secure transfer protocol.
To use non-anonymous access, chain method WithCredentials() to the client object along with the access key & secret key.
Finally chain the method Build() to get the finally built client object.
Endpoint
Chain .WithEndpoint() to MinIO Client object to initialize the endpoint.
Return TypeExceptions
MinioClientListed Exceptions:

Examples

MinIO

// 1. Using Builder with public MinioClient(), Endpoint, Credentials & Secure (HTTPS) connectionIMinioClientminioClient=newMinioClient().WithEndpoint("play.min.io").WithCredentials("Q3AM3UQ867SPQQA43P2F","zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG").WithSSL().Build()// 2. Using Builder with public MinioClient(), Endpoint, Credentials & Secure (HTTPS) connectionIMinioClientminioClient=newMinioClient().WithEndpoint("play.min.io",9000,true).WithCredentials("Q3AM3UQ867SPQQA43P2F","zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG").WithSSL().Build()// 3. Initializing minio client with proxyIWebProxyproxy=newWebProxy("192.168.0.1",8000);IMinioClientminioClient=newMinioClient().WithEndpoint("my-ip-address:9000").WithCredentials("minio","minio123").WithSSL().WithProxy(proxy).Build();

AWS S3

// 1. Using Builder with public MinioClient(), Endpoint, Credentials, Secure (HTTPS) connection & proxyIMinioClients3Client=newMinioClient().WithEndpoint("s3.amazonaws.com").WithCredentials("YOUR-AWS-ACCESSKEYID","YOUR-AWS-SECRETACCESSKEY").WithSSL().WithProxy(proxy).Build();

2. Bucket operations

MakeBucketAsync(string bucketName, string location = “us-east-1”)

Task MakeBucketAsync(string bucketName, string location = "us-east-1", CancellationToken cancellationToken = default(CancellationToken))

Creates a new bucket.

Parameters

ParamTypeDescription
bucketNamestringName of the bucket
regionstringOptional parameter. Defaults to us-east-1 for AWS requests
cancellationTokenSystem.Threading.CancellationTokenOptional parameter. Defaults to default(CancellationToken)
Return TypeExceptions
TaskListed Exceptions:
InvalidBucketNameException : upon invalid bucket name
ConnectionException : upon connection error
AccessDeniedException : upon access denial
RedirectionException : upon redirection by server
InternalClientException : upon internal library error

Example

try{// Create bucket if it doesn't exist.boolfound=awaitminioClient.BucketExistsAsync("mybucket");if(found){Console.WriteLine("mybucket already exists");}else{// Create bucket 'my-bucketname'.awaitminioClient.MakeBucketAsync("mybucket");Console.WriteLine("mybucket is created successfully");}}catch(MinioExceptione){Console.WriteLine("Error occurred: "+e);}

MakeBucketAsync(MakeBucketArgs args)

Task MakeBucketAsync(MakeBucketArgs args, CancellationToken cancellationToken = default(CancellationToken))

Creates a new bucket.

Parameters

ParamTypeDescription
argsMakeBucketArgsArguments Object - name, location.
cancellationTokenSystem.Threading.CancellationTokenOptional parameter. Defaults to default(CancellationToken)
Return TypeExceptions
TaskListed Exceptions:
InvalidBucketNameException : upon invalid bucket name
ConnectionException : upon connection error
AccessDeniedException : upon access denial
RedirectionException : upon redirection by server
InternalClientException : upon internal library error

Example

try{// Create bucket if it doesn't exist.boolfound=awaitminioClient.BucketExistsAsync(bktExistArgs);if(found){Console.WriteLine(bktExistArgs.BucketName+" already exists");}else{// Create bucket 'my-bucketname'.awaitminioClient.MakeBucketAsync(mkBktArgs);Console.WriteLine(mkBktArgs.BucketName+" is created successfully");}}catch(MinioExceptione){Console.WriteLine("Error occurred: "+e);}

ListBucketsAsync()

Task<ListAllMyBucketsResult> ListBucketsAsync(CancellationToken cancellationToken = default(CancellationToken))

Lists all buckets.

ParamTypeDescription
cancellationTokenSystem.Threading.CancellationTokenOptional parameter. Defaults to default(CancellationToken)
Return TypeExceptions
Task<ListAllMyBucketsResult> : Task with List of bucket type.Listed Exceptions:
InvalidBucketNameException : upon invalid bucket name
ConnectionException : upon connection error
AccessDeniedException : upon access denial
InvalidOperationException: upon unsuccessful deserialization of xml data
ErrorResponseException : upon unsuccessful execution
InternalClientException : upon internal library error

Example

try{// List buckets that have read access.varlist=awaitminioClient.ListBucketsAsync();foreach(Bucketbucketinlist.Buckets){Console.WriteLine(bucket.Name+" "+bucket.CreationDateDateTime);}}catch(MinioExceptione){Console.WriteLine("Error occurred: "+e);}

BucketExistsAsync(string bucketName)

Task<bool> BucketExistsAsync(string bucketName, CancellationToken cancellationToken = default(CancellationToken))

Checks if a bucket exists.

Parameters

ParamTypeDescription
bucketNamestringName of the bucket.
cancellationTokenSystem.Threading.CancellationTokenOptional parameter. Defaults to default(CancellationToken)
Return TypeExceptions
Task<bool> : true if the bucket existsListed Exceptions:
InvalidBucketNameException : upon invalid bucket name
ConnectionException : upon connection error
AccessDeniedException : upon access denial
ErrorResponseException : upon unsuccessful execution
InternalClientException : upon internal library error

Example

try{// Check whether 'my-bucketname' exists or not.boolfound=awaitminioClient.BucketExistsAsync(bucketName);Console.WriteLine("bucket-name "+((found==true)?"exists":"does not exist"));}catch(MinioExceptione){Console.WriteLine("[Bucket]  Exception: {0}",e);}

BucketExistsAsync(BucketExistsArgs)

Task<bool> BucketExistsAsync(BucketExistsArgs args, CancellationToken cancellationToken = default(CancellationToken))

Checks if a bucket exists.

Parameters

ParamTypeDescription
argsBucketExistsArgsArgument object - bucket name.
cancellationTokenSystem.Threading.CancellationTokenOptional parameter. Defaults to default(CancellationToken)
Return TypeExceptions
Task<bool> : true if the bucket existsListed Exceptions:
InvalidBucketNameException : upon invalid bucket name
ConnectionException : upon connection error
AccessDeniedException : upon access denial
ErrorResponseException : upon unsuccessful execution
InternalClientException : upon internal library error

Example

try{// Check whether 'my-bucketname' exists or not.boolfound=awaitminioClient.BucketExistsAsync(args);Console.WriteLine(args.BucketName+" "+((found==true)?"exists":"does not exist"));}catch(MinioExceptione){Console.WriteLine("[Bucket]  Exception: {0}",e);}

RemoveBucketAsync(string bucketName)

Task RemoveBucketAsync(string bucketName, CancellationToken cancellationToken = default(CancellationToken))

Removes a bucket.

NOTE: - removeBucket does not delete the objects inside the bucket. The objects need to be deleted using the removeObject API.

Parameters

ParamTypeDescription
bucketNamestringName of the bucket
cancellationTokenSystem.Threading.CancellationTokenOptional parameter. Defaults to default(CancellationToken)
Return TypeExceptions
TaskListed Exceptions:
InvalidBucketNameException : upon invalid bucket name
ConnectionException : upon connection error
AccessDeniedException : upon access denial
ErrorResponseException : upon unsuccessful execution
InternalClientException : upon internal library error
BucketNotFoundException : upon missing bucket

Example

try{// Check if my-bucket exists before removing it.boolfound=awaitminioClient.BucketExistsAsync("mybucket");if(found){// Remove bucket my-bucketname. This operation will succeed only if the bucket is empty.awaitminioClient.RemoveBucketAsync("mybucket");Console.WriteLine("mybucket is removed successfully");}else{Console.WriteLine("mybucket does not exist");}}catch(MinioExceptione){Console.WriteLine("Error occurred: "+e);}

RemoveBucketAsync(RemoveBucketArgs args)

Task RemoveBucketAsync(RemoveBucketArgs args, CancellationToken cancellationToken = default(CancellationToken))

Removes a bucket.

NOTE: - removeBucket does not delete the objects inside the bucket. The objects need to be deleted using the removeObject API.

Parameters

ParamTypeDescription
argsRemoveBucketArgsArguments Object - bucket name
cancellationTokenSystem.Threading.CancellationTokenOptional parameter. Defaults to default(CancellationToken)
Return TypeExceptions
TaskListed Exceptions:
InvalidBucketNameException : upon invalid bucket name
ConnectionException : upon connection error
AccessDeniedException : upon access denial
ErrorResponseException : upon unsuccessful execution
InternalClientException : upon internal library error
BucketNotFoundException : upon missing bucket

Example

try{// Check if my-bucket exists before removing it.boolfound=awaitminioClient.BucketExistsAsync(bktExistsArgs);if(found){// Remove bucket my-bucketname. This operation will succeed only if the bucket is empty.awaitminioClient.RemoveBucketAsync(rmBktArgs);Console.WriteLine(rmBktArgs.BucketName+" is removed successfully");}else{Console.WriteLine(bktExistsArgs.BucketName+" does not exist");}}catch(MinioExceptione){Console.WriteLine("Error occurred: "+e);}

public async Task GetVersioningAsync(GetVersioningArgs args)

Task<VersioningConfiguration> GetVersioningAsync(GetVersioningArgs args, CancellationToken cancellationToken = default(CancellationToken))

Get versioning information for a bucket.

Parameters

ParamTypeDescription
argsGetVersioningArgsArguments Object - bucket name.
cancellationTokenSystem.Threading.CancellationTokenOptional parameter. Defaults to default(CancellationToken)
Return TypeExceptions
VersioningConfiguration:VersioningConfiguration with information populated from response.None

Example

try{// Check whether 'mybucket' exists or not.boolfound=minioClient.BucketExistsAsync(bktExistsArgs);if(found){varargs=newGetVersioningArgs("mybucket").WithSSL();VersioningConfigurationvc=awaitminio.GetVersioningInfoAsync(args);}else{Console.WriteLine(bktExistsArgs.BucketName+" does not exist");}}catch(MinioExceptione){Console.WriteLine("Error occurred: "+e);}

public async Task SetVersioningAsync(SetVersioningArgs args)

Task SetVersioningAsync(SetVersioningArgs args, CancellationToken cancellationToken = default(CancellationToken))

Set versioning to Enabled or Suspended for a bucket.

Parameters

ParamTypeDescription
argsSetVersioningArgsArguments Object - bucket name, versioning status.
cancellationTokenSystem.Threading.CancellationTokenOptional parameter. Defaults to default(CancellationToken)
Return TypeExceptions
Task:None

Example

try{// Check whether 'mybucket' exists or not.boolfound=minioClient.BucketExistsAsync(bktExistsArgs);if(found){varargs=newSetVersioningArgs("mybucket").WithSSL().WithVersioningEnabled();awaitminio.SetVersioningAsync(setArgs);}else{Console.WriteLine(bktExistsArgs.BucketName+" does not exist");}}catch(MinioExceptione){Console.WriteLine("Error occurred: "+e);}

SetBucketEncryptionAsync(SetBucketEncryptionArgs args)

Task SetBucketEncryptionAsync(SetBucketEncryptionArgs args, CancellationToken cancellationToken = default(CancellationToken));

Sets the Bucket Encryption Configuration of a bucket.

Parameters

ParamTypeDescription
argsSetBucketEncryptionArgsSetBucketEncryptionArgs Argument Object with bucket, encryption configuration
cancellationTokenSystem.Threading.CancellationTokenOptional parameter. Defaults to default(CancellationToken)
Return TypeExceptions
TaskListed Exceptions:
AuthorizationException : upon access or secret key wrong or not found
InvalidBucketNameException : upon invalid bucket name
BucketNotFoundException : upon bucket with name not found
MalFormedXMLException : upon configuration XML in http request validation failure
UnexpectedMinioException : upon internal errors encountered during the operation

Example

try{// Set Encryption Configuration for the bucketSetBucketEncryptionArgsargs=newSetBucketEncryptionArgs().WithBucket(bucketName).WithEncryptionConfig(config);awaitminio.SetBucketEncryptionAsync(args);}catch(MinioExceptione){Console.WriteLine("Error occurred: "+e);}

GetBucketEncryptionAsync(GetBucketEncryptionArgs args)

Task<ServerSideEncryptionConfiguration> GetBucketEncryptionAsync(GetBucketEncryptionArgs args, CancellationToken cancellationToken = default(CancellationToken))

Gets the Bucket Encryption configuration of the bucket.

Parameters

ParamTypeDescription
argsGetBucketEncryptionArgsGetBucketEncryptionArgs Argument Object with bucket name
cancellationTokenSystem.Threading.CancellationTokenOptional parameter. Defaults to default(CancellationToken)
Return TypeExceptions
Task<ServerSideEncryptionConfiguration>Listed Exceptions:
AuthorizationException : upon access or secret key wrong or not found
InvalidBucketNameException : upon invalid bucket name
BucketNotFoundException : upon bucket with name not found
MalFormedXMLException : upon configuration XML in http request validation failure
UnexpectedMinioException : upon internal errors encountered during the operation

ServerSideEncryptionConfiguration object which contains the bucket encryption configuration.

Example

try{// Get Bucket Encryption Configuration for the bucketvarargs=newGetBucketEncryptionArgs().WithBucket(bucketName);ServerSideEncryptionConfigurationconfig=awaitminio.GetBucketEncryptionAsync(args);Console.WriteLine($"Got encryption configuration for bucket {bucketName}.");}catch(MinioExceptione){Console.WriteLine("Error occurred: "+e);}

RemoveBucketEncryptionAsync(RemoveBucketEncryptionArgs args)

Task RemoveBucketEncryptionAsync(RemoveBucketEncryptionArgs args, CancellationToken cancellationToken = default(CancellationToken))

Remove the Bucket Encryption configuration of an object.

Parameters

ParamTypeDescription
argsRemoveBucketEncryptionArgsRemoveBucketEncryptionArgs Argument Object with bucket name
cancellationTokenSystem.Threading.CancellationTokenOptional parameter. Defaults to default(CancellationToken)
Return TypeExceptions
TaskListed Exceptions:
AuthorizationException : upon access or secret key wrong or not found
InvalidBucketNameException : upon invalid bucket name
BucketNotFoundException : upon bucket with name not found
MalFormedXMLException : upon configuration XML in http request validation failure
UnexpectedMinioException : upon internal errors encountered during the operation

Example

try{// Remove Bucket Encryption Configuration for the bucketvarargs=newRemoveBucketEncryptionArgs().WithBucket(bucketName);awaitminio.RemoveBucketEncryptionAsync(args);Console.WriteLine($"Removed encryption configuration for bucket {bucketName}.");}catch(MinioExceptione){Console.WriteLine("Error occurred: "+e);}

SetBucketTagsAsync(SetBucketTagsArgs args)

Task SetBucketTagsAsync(SetBucketTagsArgs args, CancellationToken cancellationToken = default(CancellationToken))

Sets tags to a bucket.

Parameters

ParamTypeDescription
argsSetBucketTagsArgsSetBucketTagsArgs Argument Object with bucket, tags to set
cancellationTokenSystem.Threading.CancellationTokenOptional parameter. Defaults to default(CancellationToken)
Return TypeExceptions
TaskListed Exceptions:
AuthorizationException : upon access or secret key wrong or not found
InvalidBucketNameException : upon invalid bucket name
BucketNotFoundException : upon bucket with name not found
MalFormedXMLException : upon configuration XML in http request validation failure
UnexpectedMinioException : upon internal errors encountered during the operation

Example

try{// Set Tags for the bucketSetBucketTagsArgsargs=newSetBucketTagsArgs().WithBucket(bucketName).WithTagging(tags);awaitminio.SetBucketTagsAsync(args);Console.WriteLine($"Set Tags for bucket {bucketName}.");}catch(MinioExceptione){Console.WriteLine("Error occurred: "+e);}

GetBucketTagsAsync(GetBucketTagsArgs args)

Task<Tagging> GetBucketTagsAsync(GetBucketTagsArgs args, CancellationToken cancellationToken = default(CancellationToken))

Gets tags of a bucket.

Parameters

ParamTypeDescription
argsGetBucketTagsArgsGetBucketTagsArgs Argument Object with bucket name
cancellationTokenSystem.Threading.CancellationTokenOptional parameter. Defaults to default(CancellationToken)
Return TypeExceptions
Task<Tagging>: Tagging object which containing tag-value pairs.Listed Exceptions:
AuthorizationException : upon access or secret key wrong or not found
InvalidBucketNameException : upon invalid bucket name
BucketNotFoundException : upon bucket with name not found
MalFormedXMLException : upon configuration XML in http request validation failure
UnexpectedMinioException : upon internal errors encountered during the operation

Example

try{// Get Bucket Tags for the bucketvarargs=newGetBucketTagsArgs().WithBucket(bucketName);vartags=awaitminio.GetBucketTagsAsync(args);Console.WriteLine($"Got tags for bucket {bucketName}.");}catch(MinioExceptione){Console.WriteLine("Error occurred: "+e);}

RemoveBucketTagsAsync(RemoveBucketTagsArgs args)

Task RemoveBucketTagsAsync(RemoveBucketTagsArgs args, CancellationToken cancellationToken = default(CancellationToken))

Deletes tags of a bucket.

Parameters

ParamTypeDescription
argsRemoveBucketTagsArgsRemoveBucketTagsArgs Argument Object with bucket name
cancellationTokenSystem.Threading.CancellationTokenOptional parameter. Defaults to default(CancellationToken)
Return TypeExceptions
TaskListed Exceptions:
AuthorizationException : upon access or secret key wrong or not found
InvalidBucketNameException : upon invalid bucket name
BucketNotFoundException : upon bucket with name not found
MalFormedXMLException : upon configuration XML in http request validation failure
UnexpectedMinioException : upon internal errors encountered during the operation

Example

try{// Remove Bucket Encryption Configuration for the bucketvarargs=newRemoveBucketTagsArgs().WithBucket(bucketName);awaitminio.RemoveBucketTagsAsync(args);Console.WriteLine($"Removed tags for bucket {bucketName}.");}catch(MinioExceptione){Console.WriteLine("Error occurred: "+e);}

SetBucketLifecycleAsync(SetBucketLifecycleArgs args)

Task SetBucketLifecycleAsync(SetBucketLifecycleArgs args, CancellationToken cancellationToken = default(CancellationToken))

Sets Lifecycle configuration to a bucket.

Parameters

ParamTypeDescription
argsSetBucketLifecycleArgsSetBucketLifecycleArgs Argument Object with bucket name, Lifecycle configuration to set
cancellationTokenSystem.Threading.CancellationTokenOptional parameter. Defaults to default(CancellationToken)
Return TypeExceptions
TaskListed Exceptions:
AuthorizationException : upon access or secret key wrong or not found
InvalidBucketNameException : upon invalid bucket name
BucketNotFoundException : upon bucket with name not found
MalFormedXMLException : upon configuration XML in http request validation failure
UnexpectedMinioException : upon internal errors encountered during the operation

Example

try{// Set Lifecycle configuration for the bucketSetBucketLifecycleArgsargs=newSetBucketLifecycleArgs().WithBucket(bucketName).WithConfiguration(lfc);awaitminio.SetBucketLifecycleAsync(args);Console.WriteLine($"Set Lifecycle for bucket {bucketName}.");}catch(MinioExceptione){Console.WriteLine("Error occurred: "+e);}

GetBucketLifecycleAsync(GetBucketLifecycleArgs args)

Task<LifecycleConfiguration> GetBucketLifecycleAsync(GetBucketLifecycleArgs args, CancellationToken cancellationToken = default(CancellationToken))

Gets Lifecycle configuration of a bucket.

Parameters

ParamTypeDescription
argsGetBucketLifecycleArgsGetBucketLifecycleArgs Argument Object with bucket name
cancellationTokenSystem.Threading.CancellationTokenOptional parameter. Defaults to default(CancellationToken)
Return TypeExceptions
Task<LifecycleConfiguration>: LifecycleConfiguration object which contains the Lifecycle configuration details.Listed Exceptions:
AuthorizationException : upon access or secret key wrong or not found
InvalidBucketNameException : upon invalid bucket name
BucketNotFoundException : upon bucket with name not found
MalFormedXMLException : upon configuration XML in http request validation failure
UnexpectedMinioException : upon internal errors encountered during the operation

Example

try{// Get Bucket Lifecycle configuration for the bucketvarargs=newGetBucketLifecycleArgs().WithBucket(bucketName);varlfc=awaitminio.GetBucketLifecycleAsync(args);Console.WriteLine($"Got Lifecycle configuration for bucket {bucketName}.");}catch(MinioExceptione){Console.WriteLine("Error occurred: "+e);}

RemoveBucketLifecycleAsync(RemoveBucketLifecycleArgs args)

Task RemoveBucketLifecycleAsync(RemoveBucketLifecycleArgs args, CancellationToken cancellationToken = default(CancellationToken))

Deletes Lifecycle configuration of a bucket.

Parameters

ParamTypeDescription
argsRemoveBucketLifecycleArgsRemoveBucketLifecycleArgs Argument Object with bucket name
cancellationTokenSystem.Threading.CancellationTokenOptional parameter. Defaults to default(CancellationToken)
Return TypeExceptions
TaskListed Exceptions:
AuthorizationException : upon access or secret key wrong or not found
InvalidBucketNameException : upon invalid bucket name
BucketNotFoundException : upon bucket with name not found
MalFormedXMLException : upon configuration XML in http request validation failure
UnexpectedMinioException : upon internal errors encountered during the operation

Example

try{// Remove Bucket Lifecycle Configuration for the bucketvarargs=newRemoveBucketLifecycleArgs().WithBucket(bucketName);awaitminio.RemoveBucketLifecycleAsync(args);Console.WriteLine($"Removed Lifecycle configuration for bucket {bucketName}.");}catch(MinioExceptione){Console.WriteLine("Error occurred: "+e);}

SetBucketReplicationAsync(SetBucketReplicationArgs args)

Task SetBucketReplicationAsync(SetBucketReplicationArgs args, CancellationToken cancellationToken = default(CancellationToken))

Sets Replication configuration to a bucket.

Parameters

ParamTypeDescription
argsSetBucketReplicationArgsSetBucketReplicationArgs Argument Object with bucket name, Replication configuration to set
cancellationTokenSystem.Threading.CancellationTokenOptional parameter. Defaults to default(CancellationToken)
Return TypeExceptions
TaskListed Exceptions:
AuthorizationException : upon access or secret key wrong or not found
InvalidBucketNameException : upon invalid bucket name
BucketNotFoundException : upon bucket with name not found
MalFormedXMLException : upon configuration XML in http request validation failure
UnexpectedMinioException : upon internal errors encountered during the operation

Example

try{// Set Replication configuration for the bucketSetBucketReplicationArgsargs=newSetBucketReplicationArgs().WithBucket(bucketName).WithConfiguration(cfg);awaitminio.SetBucketReplicationAsync(args);Console.WriteLine($"Set Replication configuration for bucket {bucketName}.");}catch(MinioExceptione){Console.WriteLine("Error occurred: "+e);}

GetBucketReplicationAsync(GetBucketReplicationArgs args)

Task<ReplicationConfiguration> GetBucketReplicationAsync(GetBucketReplicationArgs args, CancellationToken cancellationToken = default(CancellationToken))

Gets Replication configuration of a bucket.

Parameters

ParamTypeDescription
argsGetBucketReplicationArgsGetBucketReplicationArgs Argument Object with bucket name
cancellationTokenSystem.Threading.CancellationTokenOptional parameter. Defaults to default(CancellationToken)
Return TypeExceptions
Task<ReplicationConfiguration>: ReplicationConfiguration object which contains the Replication configuration details.Listed Exceptions:
AuthorizationException : upon access or secret key wrong or not found
InvalidBucketNameException : upon invalid bucket name
BucketNotFoundException : upon bucket with name not found
MalFormedXMLException : upon configuration XML in http request validation failure
UnexpectedMinioException : upon internal errors encountered during the operation

Example

try{// Get Bucket Replication for the bucketvarargs=newGetBucketReplicationArgs().WithBucket(bucketName);varcfg=awaitminio.GetBucketReplicationAsync(args);Console.WriteLine($"Got Replication configuration for bucket {bucketName}.");}catch(MinioExceptione){Console.WriteLine("Error occurred: "+e);}

RemoveBucketReplicationAsync(RemoveBucketReplicationArgs args)

Task RemoveBucketReplicationAsync(RemoveBucketReplicationArgs args, CancellationToken cancellationToken = default(CancellationToken))

Deletes Replication configuration of a bucket.

Parameters

ParamTypeDescription
argsRemoveBucketReplicationArgsRemoveBucketReplicationArgs Argument Object with bucket name
cancellationTokenSystem.Threading.CancellationTokenOptional parameter. Defaults to default(CancellationToken)
Return TypeExceptions
TaskListed Exceptions:
AuthorizationException : upon access or secret key wrong or not found
InvalidBucketNameException : upon invalid bucket name
BucketNotFoundException : upon bucket with name not found
MalFormedXMLException : upon configuration XML in http request validation failure
UnexpectedMinioException : upon internal errors encountered during the operation

Example

try{// Remove Bucket Replication Configuration for the bucketvarargs=newRemoveBucketReplicationArgs().WithBucket(bucketName);awaitminio.RemoveBucketReplicationAsync(args);Console.WriteLine($"Removed Replication configuration for bucket {bucketName}.");}catch(MinioExceptione){Console.WriteLine("Error occurred: "+e);}

ListObjectsAsync(ListObjectArgs args)

IObservable<Item> ListObjectsAsync(ListObjectArgs args, CancellationToken cancellationToken = default(CancellationToken))

Lists all objects (with version IDs, if existing) in a bucket.

Parameters

ParamTypeDescription
argsListObjectArgsListObjectArgs object - encapsulates bucket name, prefix, show recursively, show versions.
cancellationTokenSystem.Threading.CancellationTokenOptional parameter. Defaults to default(CancellationToken)
Return TypeExceptions
IObservable<Item>:an Observable of Items.None

Example

try{// Just list of objects// Check whether 'mybucket' exists or not.boolfound=minioClient.BucketExistsAsync("mybucket");if(found){// List objects from 'my-bucketname'ListObjectArgsargs=newListObjectArgs().WithBucket("mybucket").WithPrefix("prefix").WithRecursive(true);IObservable<Item>observable=minioClient.ListObjectsAsync(args);IDisposablesubscription=observable.Subscribe(item=>Console.WriteLine("OnNext: {0}",item.Key),ex=>Console.WriteLine("OnError: {0}",ex.Message),()=>Console.WriteLine("OnComplete: {0}"));}else{Console.WriteLine("mybucket does not exist");}}catch(MinioExceptione){Console.WriteLine("Error occurred: "+e);}try{// List of objects with version IDs.// Check whether 'mybucket' exists or not.boolfound=minioClient.BucketExistsAsync("mybucket");if(found){// List objects from 'my-bucketname'ListObjectArgsargs=newListObjectArgs().WithBucket("mybucket").WithPrefix("prefix").WithRecursive(true).WithVersions(true)IObservable<Item>observable=minioClient.ListObjectsAsync(args,true);IDisposablesubscription=observable.Subscribe(item=>Console.WriteLine("OnNext: {0} - {1}",item.Key,item.VersionId),ex=>Console.WriteLine("OnError: {0}",ex.Message),()=>Console.WriteLine("OnComplete: {0}"));}else{Console.WriteLine("mybucket does not exist");}}catch(MinioExceptione){Console.WriteLine("Error occurred: "+e);}

SetObjectLockConfigurationAsync(SetObjectLockConfigurationArgs args)

Task SetObjectLockConfigurationAsync(SetObjectLockConfigurationArgs args, CancellationToken cancellationToken = default(CancellationToken))

Sets object-lock configuration in a bucket.

Parameters

ParamTypeDescription
argsSetObjectLockConfigurationArgsSetObjectLockConfigurationArgs Argument Object with bucket, lock configuration to set
cancellationTokenSystem.Threading.CancellationTokenOptional parameter. Defaults to default(CancellationToken)
Return TypeExceptions
TaskListed Exceptions:
AuthorizationException : upon access or secret key wrong or not found
InvalidBucketNameException : upon invalid bucket name
BucketNotFoundException : upon bucket with name not found
MalFormedXMLException : upon configuration XML in http request validation failure
UnexpectedMinioException : upon internal errors encountered during the operation

Example

try{ObjectLockConfigurationconfig==newObjectLockConfiguration(RetentionMode.GOVERNANCE,35);// Set Object Lock Configuration for the bucketSetObjectLockConfigurationArgsargs=newSetObjectLockConfigurationArgs().WithBucket(bucketName).WithLockConfiguration(config);awaitminio.SetObjectLockConfigurationAsync(args);Console.WriteLine($"Set Object lock configuration to bucket {bucketName}.");}catch(MinioExceptione){Console.WriteLine("Error occurred: "+e);}

GetObjectLockConfigurationAsync(GetObjectLockConfigurationArgs args)

Task<ObjectLockConfiguration> GetObjectLockConfigurationAsync(GetObjectLockConfigurationArgs args, CancellationToken cancellationToken = default(CancellationToken))

Gets object-lock configuration of a bucket.

Parameters

ParamTypeDescription
argsGetObjectLockConfigurationArgsGetObjectLockConfigurationArgs Argument Object with bucket name
cancellationTokenSystem.Threading.CancellationTokenOptional parameter. Defaults to default(CancellationToken)
Return TypeExceptions
Task<ObjectLockConfiguration>: ObjectLockConfiguration object which containing lock-enabled status & Object lock rule.Listed Exceptions:
AuthorizationException : upon access or secret key wrong or not found
InvalidBucketNameException : upon invalid bucket name
BucketNotFoundException : upon bucket with name not found
MalFormedXMLException : upon configuration XML in http request validation failure
UnexpectedMinioException : upon internal errors encountered during the operation

Example

try{// Get the Object Lock Configuration for the bucketvarargs=newGetObjectLockConfigurationArgs().WithBucket(bucketName);varconfig=awaitminio.GetObjectLockConfigurationAsync(args);Console.WriteLine($"Object lock configuration on bucket {bucketName} is : "+config.ObjectLockEnabled);}catch(MinioExceptione){Console.WriteLine("Error occurred: "+e);}

RemoveObjectLockConfigurationAsync(RemoveObjectLockConfigurationArgs args)

Task RemoveObjectLockConfigurationAsync(RemoveObjectLockConfigurationArgs args, CancellationToken cancellationToken = default(CancellationToken))

Removes object-lock configuration on a bucket.

Parameters

ParamTypeDescription
argsRemoveObjectLockConfigurationArgsRemoveObjectLockConfigurationArgs Argument Object with bucket name
cancellationTokenSystem.Threading.CancellationTokenOptional parameter. Defaults to default(CancellationToken)
Return TypeExceptions
TaskListed Exceptions:
AuthorizationException : upon access or secret key wrong or not found
InvalidBucketNameException : upon invalid bucket name
BucketNotFoundException : upon bucket with name not found
MalFormedXMLException : upon configuration XML in http request validation failure
UnexpectedMinioException : upon internal errors encountered during the operation

Example

try{// Remove Object Lock Configuration on the bucketvarargs=newRemoveObjectLockConfigurationArgs().WithBucket(bucketName);awaitminio.RemoveObjectLockConfigurationAsync(args);Console.WriteLine($"Removed Object lock configuration on bucket {bucketName}.");}catch(MinioExceptione){Console.WriteLine("Error occurred: "+e);}

ListIncompleteUploads(ListIncompleteUploadsArgs args)

IObservable<Upload> ListIncompleteUploads(ListIncompleteUploadsArgs args, CancellationToken cancellationToken = default(CancellationToken))

Lists partially uploaded objects in a bucket.

Parameters

ParamTypeDescription
argsListIncompleteUploadsArgsListIncompleteUploadsArgs object - encapsulates bucket name, prefix, show recursively.
cancellationTokenSystem.Threading.CancellationTokenOptional parameter. Defaults to default(CancellationToken)
Return TypeExceptions
IObservable<Upload>: an Observable of Upload.None

Example

try{// Check whether 'mybucket' exist or not.boolfound=minioClient.BucketExistsAsync("mybucket");if(found){// List all incomplete multipart upload of objects in 'mybucket'ListIncompleteUploadsArgslistArgs=newListIncompleteUploadsArgs().WithBucket("mybucket").WithPrefix("prefix").WithRecursive(true);IObservable<Upload>observable=minioClient.ListIncompleteUploads(listArgs);IDisposablesubscription=observable.Subscribe(item=>Console.WriteLine("OnNext: {0}",item.Key),ex=>Console.WriteLine("OnError: {0}",ex.Message),()=>Console.WriteLine("OnComplete: {0}"));}else{Console.WriteLine("mybucket does not exist");}}catch(MinioExceptione){Console.WriteLine("Error occurred: "+e);}

ListenBucketNotificationsAsync(ListenBucketNotificationsArgs args)

IObservable<MinioNotificationRaw> ListenBucketNotificationsAsync(ListenBucketNotificationsArgs args, CancellationToken cancellationToken = default(CancellationToken))

Subscribes to bucket change notifications (a Minio-only extension)

Parameters

ParamTypeDescription
argsListenBucketNotificationsArgsListenBucketNotificationsArgs object - encapsulates bucket name, list of events, prefix, suffix.
cancellationTokenSystem.Threading.CancellationTokenOptional parameter. Defaults to default(CancellationToken)
Return TypeExceptions
IObservable<MinioNotificationRaw>: an Observable ofMinioNotificationRaw, which contain the raw JSON notifications. Use theMinioNotification class to deserialise using the JSON library of your choice.None

Example

try{varevents=newList<EventType>{EventType.ObjectCreatedAll};varprefix=null;varsuffix=null;ListenBucketNotificationsArgsargs=newListenBucketNotificationsArgs().WithBucket(bucketName).WithEvents(events).WithPrefix(prefix).WithSuffix(suffix);IObservable<MinioNotificationRaw>observable=minioClient.ListenBucketNotificationsAsync(args);IDisposablesubscription=observable.Subscribe(notification=>Console.WriteLine($"Notification: {notification.json}"),ex=>Console.WriteLine($"OnError: {ex}"),()=>Console.WriteLine($"Stopped listening for bucket notifications\n"));}catch(MinioExceptione){Console.WriteLine("Error occurred: "+e);}

GetPolicyAsync(GetPolicyArgs args)

Task<String> GetPolicyAsync(GetPolicyArgs args, CancellationToken cancellationToken = default(CancellationToken))

Get bucket policy.

Parameters

ParamTypeDescription
argsGetPolicyArgsGetPolicyArgs object encapsulating bucket name.
cancellationTokenSystem.Threading.CancellationTokenOptional parameter. Defaults to default(CancellationToken)
Return TypeExceptions
Task<String>: The current bucket policy for given bucket as a json string.Listed Exceptions:
InvalidBucketNameException : upon invalid bucket name.
InvalidObjectPrefixException : upon invalid object prefix.
ConnectionException : upon connection error.
AccessDeniedException : upon access denial
InternalClientException : upon internal library error.
BucketNotFoundException : upon missing bucket

Example

try{GetPolicyArgsargs=newGetPolicyArgs().WithBucket("myBucket");StringpolicyJson=awaitminioClient.GetPolicyAsync(args);Console.WriteLine("Current policy: "+policyJson);}catch(MinioExceptione){Console.WriteLine("Error occurred: "+e);}

SetPolicyAsync(SetPolicyArgs args)

Task SetPolicyAsync(SetPolicyArgs args, CancellationToken cancellationToken = default(CancellationToken))

Set policy on bucket.

Parameters

ParamTypeDescription
argsSetPolicyArgsSetPolicyArgs object encapsulating bucket name, Policy as a json string.
cancellationTokenSystem.Threading.CancellationTokenOptional parameter. Defaults to default(CancellationToken)
Return TypeExceptions
TaskListed Exceptions:
InvalidBucketNameException : upon invalid bucket name
ConnectionException : upon connection error
InternalClientException : upon internal library error
InvalidBucketNameException : upon invalid bucket name
InvalidObjectPrefixException : upon invalid object prefix

Example

try{stringpolicyJson=$@"{{""Version"":""2012-10-17"",""Statement"":[{{""Action"":[""s3:GetBucketLocation""],""Effect"":""Allow"",""Principal"":{{""AWS"":[""*""]}},""Resource"":[""arn:aws:s3:::{bucketName}""],""Sid"":""""}},{{""Action"":[""s3:ListBucket""],""Condition"":{{""StringEquals"":{{""s3:prefix"":[""foo"",""prefix/""]}}}},""Effect"":""Allow"",""Principal"":{{""AWS"":[""*""]}},""Resource"":[""arn:aws:s3:::{bucketName}""],""Sid"":""""}},{{""Action"":[""s3:GetObject""],""Effect"":""Allow"",""Principal"":{{""AWS"":[""*""]}},""Resource"":[""arn:aws:s3:::{bucketName}/foo*"",""arn:aws:s3:::{bucketName}/prefix/*""],""Sid"":""""}}]}}";SetPolicyArgsargs=newSetPolicyArgs().WithBucket("myBucket").WithPolicy(policyJson);awaitminioClient.SetPolicyAsync(args);}catch(MinioExceptione){Console.WriteLine("Error occurred: "+e);}

SetBucketNotificationAsync(SetBucketNotificationsArgs args)

Task SetBucketNotificationAsync(SetBucketNotificationsArgs args, CancellationToken cancellationToken = default(CancellationToken))

Sets notification configuration for a given bucket

Parameters

ParamTypeDescription
argsSetBucketNotificationsArgsSetBucketNotificationsArgs object encapsulating bucket name, notification configuration object.
cancellationTokenSystem.Threading.CancellationTokenOptional parameter. Defaults to default(CancellationToken)
Return TypeExceptions
TaskListed Exceptions:
ConnectionException : upon connection error
InternalClientException : upon internal library error
InvalidBucketNameException : upon invalid bucket name
InvalidOperationException: upon unsuccessful serialization of notification object

Example

try{BucketNotificationnotification=newBucketNotification();ArntopicArn=newArn("aws","sns","us-west-1","412334153608","topicminio");TopicConfigtopicConfiguration=newTopicConfig(topicArn);List<EventType>events=newList<EventType>(){EventType.ObjectCreatedPut,EventType.ObjectCreatedCopy};topicConfiguration.AddEvents(events);topicConfiguration.AddFilterPrefix("images");topicConfiguration.AddFilterSuffix("jpg");notification.AddTopic(topicConfiguration);QueueConfigqueueConfiguration=newQueueConfig("arn:aws:sqs:us-west-1:482314153608:testminioqueue1");queueConfiguration.AddEvents(newList<EventType>(){EventType.ObjectCreatedCompleteMultipartUpload});notification.AddQueue(queueConfiguration);SetBucketNotificationsArgsargs=newSetBucketNotificationsArgs().WithBucket(bucketName).WithBucketNotificationConfiguration(notification);awaitminio.SetBucketNotificationsAsync(args);Console.WriteLine("Notifications set for the bucket "+args.BucketName+" successfully");}catch(MinioExceptione){Console.WriteLine("Error occurred: "+e);}

GetBucketNotificationAsync(GetBucketNotificationsArgs args)

Task<BucketNotification> GetBucketNotificationAsync(GetBucketNotificationsArgs args, CancellationToken cancellationToken = default(CancellationToken))

Get bucket notification configuration

Parameters

ParamTypeDescription
argsGetBucketNotificationsArgsGetBucketNotificationsArgs object encapsulating bucket name.
cancellationTokenSystem.Threading.CancellationTokenOptional parameter. Defaults to default(CancellationToken)
Return TypeExceptions
Task<BucketNotification>: The current notification configuration for the bucket.Listed Exceptions:
InvalidBucketNameException : upon invalid bucket name.
ConnectionException : upon connection error.
AccessDeniedException : upon access denial
InternalClientException : upon internal library error.
BucketNotFoundException : upon missing bucket
InvalidOperationException: upon unsuccessful deserialization of xml data

Example

try{GetBucketNotificationsArgsargs=newGetBucketNotificationsArgs().WithBucket(bucketName);BucketNotificationnotifications=awaitminioClient.GetBucketNotificationAsync(args);Console.WriteLine("Notifications is "+notifications.ToXML());}catch(MinioExceptione){Console.WriteLine("Error occurred: "+e);}

RemoveAllBucketNotificationsAsync(RemoveAllBucketNotificationsArgs args)

Task RemoveAllBucketNotificationsAsync(RemoveAllBucketNotificationsArgs args, CancellationToken cancellationToken = default(CancellationToken))

Remove all notification configurations set on the bucket

Parameters

ParamTypeDescription
argsRemoveAllBucketNotificationsArgsRemoveAllBucketNotificationsArgs args encapsulating the bucket name.
cancellationTokenSystem.Threading.CancellationTokenOptional parameter. Defaults to default(CancellationToken)
Return TypeExceptions
``Task`:Listed Exceptions:
InvalidBucketNameException : upon invalid bucket name.
ConnectionException : upon connection error.
AccessDeniedException : upon access denial
InternalClientException : upon internal library error.
BucketNotFoundException : upon missing bucket
InvalidOperationException: upon unsuccessful serialization of xml data

Example

try{RemoveAllBucketNotificationsArgsargs=newRemoveAllBucketNotificationsArgs().WithBucket(bucketName);awaitminioClient.RemoveAllBucketNotificationsAsync(args);Console.WriteLine("Notifications successfully removed from the bucket "+bucketName);}catch(MinioExceptione){Console.WriteLine("Error occurred: "+e);}

3. Object operations

GetObjectAsync(GetObjectArgs args, ServerSideEncryption sse)

Task GetObjectAsync(GetObjectArgs args, ServerSideEncryption sse = null, CancellationToken cancellationToken = default(CancellationToken))

Downloads an object.

Parameters

ParamTypeDescription
argsGetObjectArgsGetObjectArgs Argument Object encapsulating bucket, object names, version Id, ServerSideEncryption object, offset, length
cancellationTokenSystem.Threading.CancellationTokenOptional parameter. Defaults to default(CancellationToken)
Return TypeExceptions
Task: Task callback returns an InputStream containing the object data.Listed Exceptions:
InvalidBucketNameException : upon invalid bucket name.
ConnectionException : upon connection error.
InternalClientException : upon internal library error.

Examples

// 1. With Bucket & Object names.try{// Check whether the object exists using statObject().// If the object is not found, statObject() throws an exception,// else it means that the object exists.// Execution is successful.StatObjectArgsstatObjectArgs=newStatObjectArgs().WithBucket("mybucket").WithObject("myobject");awaitminioClient.StatObjectAsync(statObjectArgs);// Get input stream to have content of 'my-objectname' from 'my-bucketname'GetObjectArgsgetObjectArgs=newGetObjectArgs().WithBucket("mybucket").WithObject("myobject").WithCallbackStream((stream)=>{stream.CopyTo(Console.OpenStandardOutput());});awaitminioClient.GetObjectAsync(getObjectArgs);}catch(MinioExceptione){Console.WriteLine("Error occurred: "+e);}// 2. With Offset Length specifying a range of bytes & the object as a stream.try{// Check whether the object exists using statObject().// If the object is not found, statObject() throws an exception,// else it means that the object exists.// Execution is successful.StatObjectArgsstatObjectArgs=newStatObjectArgs().WithBucket("mybucket").WithObject("myobject");awaitminioClient.StatObjectAsync(statObjectArgs);// Get input stream to have content of 'my-objectname' from 'my-bucketname'GetObjectArgsgetObjectArgs=newGetObjectArgs().WithBucket("mybucket").WithObject("myobject").WithOffset(1024L).WithObjectSize(10L).WithCallbackStream((stream)=>{stream.CopyTo(Console.OpenStandardOutput());});awaitminioClient.GetObjectAsync(getObjectArgs);}catch(MinioExceptione){Console.WriteLine("Error occurred: "+e);}// 3. Downloads and saves the object as a file in the local filesystem.try{// Check whether the object exists using statObjectAsync().// If the object is not found, statObjectAsync() throws an exception,// else it means that the object exists.// Execution is successful.StatObjectArgsstatObjectArgs=newStatObjectArgs().WithBucket("mybucket").WithObject("myobject");awaitminioClient.StatObjectAsync(statObjectArgs);// Gets the object's data and stores it in photo.jpgGetObjectArgsgetObjectArgs=newGetObjectArgs().WithBucket("mybucket").WithObject("myobject").WithFileName("photo.jpg");awaitminioClient.GetObjectAsync(getObjectArgs);}catch(MinioExceptione){Console.WriteLine("Error occurred: "+e);}

PutObjectAsync(PutObjectArgs args)

Task PutObjectAsync(PutObjectArgs args, CancellationToken cancellationToken = default(CancellationToken))

PutObjectAsync: Uploads object from a file or stream.

Parameters

ParamTypeDescription
argsPutObjectArgsArguments object - bucket name, object name, file name, object data stream, object size, content type, object metadata, operation executing progress, SSE. etc.
cancellationTokenSystem.Threading.CancellationTokenOptional parameter. Defaults to default(CancellationToken)
Return TypeExceptions
TaskListed Exceptions:
AuthorizationException : upon access or secret key wrong or not found
InvalidBucketNameException : upon invalid bucket name
InvalidObjectNameException : upon invalid object name
ConnectionException : upon connection error
InternalClientException : upon internal library error
EntityTooLargeException: upon proposed upload size exceeding max allowed
UnexpectedShortReadException: data read was shorter than size of input buffer
ArgumentNullException: upon null input stream
InvalidOperationException: upon input value to PutObjectArgs being invalid

Example

The maximum size of a single object is limited to 5TB. putObject transparently uploads objects larger than 5MiB in multiple parts. Uploaded data is carefully verified using MD5SUM signatures.

try{AesaesEncryption=Aes.Create();aesEncryption.KeySize=256;aesEncryption.GenerateKey();varssec=newSSEC(aesEncryption.Key);varprogress=newProgress<ProgressReport>(progressReport=>{// Progress events are delivered asynchronously (see remark below)Console.WriteLine($"Percentage: {progressReport.Percentage}% TotalBytesTransferred: {progressReport.TotalBytesTransferred} bytes");if(progressReport.Percentage!=100)Console.SetCursorPosition(0,Console.CursorTop-1);elseConsole.WriteLine();});PutObjectArgsputObjectArgs=newPutObjectArgs().WithBucket("mybucket").WithObject("island.jpg").WithFilename("/mnt/photos/island.jpg").WithContentType("application/octet-stream").WithServerSideEncryption(ssec).WithProgress(progress);awaitminio.PutObjectAsync(putObjectArgs);Console.WriteLine("island.jpg is uploaded successfully");}catch(MinioExceptione){Console.WriteLine("Error occurred: "+e);}

Remark:Note that the defaultProgress class post progressupdates to the SynchronizationContext when the instance was constructed(source). This means that progress updates aresent asynchronous. If you do want to receive the events synchronous, then use theMinio.Helper.SyncProgress<T> instead,but make sure you understand the implications. Progress events are sent synchronous, so they may be invoked on anarbitrary thread (mostly a problem for UI applications) and performing long-running and/or blocking operations willdegrade upload performance.

StatObjectAsync(StatObjectArgs args)

Task<ObjectStat> StatObjectAsync(StatObjectArgs args, CancellationToken cancellationToken = default(CancellationToken))

Gets metadata of an object.

Parameters

ParamTypeDescription
argsStatObjectArgsStatObjectArgs Argument Object with bucket, object names & server side encryption object
cancellationTokenSystem.Threading.CancellationTokenOptional parameter. Defaults to default(CancellationToken)
Return TypeExceptions
Task<ObjectStat>: Populated object meta data.Listed Exceptions:
InvalidBucketNameException : upon invalid bucket name
ConnectionException : upon connection error
InternalClientException : upon internal library error

Example

try{// Get the metadata of the object.StatObjectArgsstatObjectArgs=newStatObjectArgs().WithBucket("mybucket").WithObject("myobject");ObjectStatobjectStat=awaitminioClient.StatObjectAsync(statObjectArgs);Console.WriteLine(objectStat);}catch(MinioExceptione){Console.WriteLine("Error occurred: "+e);}

CopyObjectAsync(CopyObjectArgs args)

Task<CopyObjectResult> CopyObjectAsync(CopyObjectArgs args, CancellationToken cancellationToken = default(CancellationToken))

Copies content from objectName to destObjectName.

Parameters

ParamTypeDescription
argsCopyObjectArgsArguments object - bucket name, object name, destination bucket name, destination object name, copy conditions, metadata, Source SSE, Destination SSE. etc.
cancellationTokenSystem.Threading.CancellationTokenOptional parameter. Defaults to default(CancellationToken)
Return TypeExceptions
TaskListed Exceptions:
AuthorizationException : upon access or secret key wrong or not found
InvalidBucketNameException : upon invalid bucket name
InvalidObjectNameException : upon invalid object name
BucketNotFoundException : upon bucket with name not found
ObjectNotFoundException : upon object with name not found
MalFormedXMLException : upon configuration XML in http request validation failure
ConnectionException : upon connection error
InternalClientException : upon internal library error
ArgumentException : upon missing bucket/object names

Example

This API performs a Server-side copy operation from a given source object to destination object.

try{CopyConditionscopyConditions=newCopyConditions();copyConditions.setMatchETagNone("TestETag");ServerSideEncryptionsseSrc,sseDst;// Uncomment to specify source and destination Server-side encryption options/*    Aes aesEncryption = Aes.Create();    aesEncryption.KeySize = 256;    aesEncryption.GenerateKey();    sseSrc = new SSEC(aesEncryption.Key);    sseDst = new SSES3();   */awaitminioClient.CopyObjectAsync("mybucket","island.jpg","mydestbucket","processed.png",copyConditions,sseSrc:sseSrc,sseDest:sseDst);Console.WriteLine("island.jpg is uploaded successfully");}catch(MinioExceptione){Console.WriteLine("Error occurred: "+e);}

RemoveObjectAsync(RemoveObjectArgs args)

Task RemoveObjectAsync(RemoveObjectArgs args, CancellationToken cancellationToken = default(CancellationToken))

Removes an object.

Parameters

ParamTypeDescription
argsRemoveObjectArgsArguments Object.
cancellationTokenSystem.Threading.CancellationTokenOptional parameter. Defaults to default(CancellationToken)
Return TypeExceptions
TaskListed Exceptions:
InvalidBucketNameException : upon invalid bucket name
ConnectionException : upon connection error
InternalClientException : upon internal library error

Example

// 1. Remove object myobject from the bucket mybucket.try{RemoveObjectArgsrmArgs=newRemoveObjectArgs().WithBucket("mybucket").WithObject("myobject");awaitminioClient.RemoveObjectAsync(args);Console.WriteLine("successfully removed mybucket/myobject");}catch(MinioExceptione){Console.WriteLine("Error: "+e);}// 2. Remove one version of object myobject with versionID from mybucket.try{RemoveObjectArgsrmArgs=newRemoveObjectArgs().WithBucket("mybucket").WithObject("myobject").WithVersionId("versionId");awaitminioClient.RemoveObjectAsync(args);Console.WriteLine("successfully removed mybucket/myobject{versionId}");}catch(MinioExceptione){Console.WriteLine("Error: "+e);}

RemoveObjectsAsync(RemoveObjectsArgs args)

Task<IObservable<DeleteError>> RemoveObjectsAsync(RemoveObjectsArgs args, CancellationToken cancellationToken = default(CancellationToken))

Removes a list of objects or object versions.

Parameters

ParamTypeDescription
argsRemoveObjectsArgsArguments Object - bucket name, List of Objects to be deleted or List of Tuples with Tuple(object name, List of version IDs).
cancellationTokenSystem.Threading.CancellationTokenOptional parameter. Defaults to default(CancellationToken)
Return TypeExceptions
TaskListed Exceptions:
InvalidBucketNameException : upon invalid bucket name
ConnectionException : upon connection error
InternalClientException : upon internal library error

Example

// 1. Remove list of objects in objectNames from the bucket bucketName.try{stringbucketName="mybucket"List<String>objectNames=newLinkedList<String>();objectNames.add("my-objectname1");objectNames.add("my-objectname2");objectNames.add("my-objectname3");RemoveObjectsAsyncrmArgs=newRemoveObjectsAsync().WithBucket(bucketName).WithObjects(objectNames);IObservable<DeleteError>observable=awaitminio.RemoveObjectAsync(rmArgs);IDisposablesubscription=observable.Subscribe(deleteError=>Console.WriteLine("Object: {0}",deleteError.Key),ex=>Console.WriteLine("OnError: {0}",ex),()=>{Console.WriteLine("Removed objects from "+bucketName+"\n");});}catch(MinioExceptione){Console.WriteLine("Error: "+e);}// 2. Remove list of objects (only specific versions mentioned in Version ID list) from the bucket bucketNametry{stringbucketName="mybucket";stringobjectName="myobject1";List<string>versionIDs=newList<string>();versionIDs.Add("abcobject1version1dce");versionIDs.Add("abcobject1version2dce");versionIDs.Add("abcobject1version3dce");List<Tuple<string,string>>objectsVersions=newList<Tuple<string,string>>();objectsVersions.Add(newTuple<string,List<string>>(objectName,versionIDs));objectsVersions.Add(newTuple<string,string>("myobject2""abcobject2version1dce"));objectsVersions.Add(newTuple<string,string>("myobject2","abcobject2version2dce"));objectsVersions.Add(newTuple<string,string>("myobject2","abcobject2version3dce"));RemoveObjectsAsyncrmArgs=newRemoveObjectsAsync().WithBucket(bucketName).WithObjectsVersions(objectsVersions);IObservable<DeleteError>observable=awaitminio.RemoveObjectsAsync(rmArgs);IDisposablesubscription=observable.Subscribe(deleteError=>Console.WriteLine("Object: {0}",deleteError.Key),ex=>Console.WriteLine("OnError: {0}",ex),()=>{Console.WriteLine("Listed all delete errors for remove objects on  "+bucketName+"\n");});}catch(MinioExceptione){Console.WriteLine("Error: "+e);}

RemoveIncompleteUploadAsync(RemoveIncompleteUploadArgs args)

Task RemoveIncompleteUploadAsync(RemoveIncompleteUploadArgs args, CancellationToken cancellationToken = default(CancellationToken))

Removes a partially uploaded object.

Parameters

ParamTypeDescription
argsRemoveIncompleteUploadArgsRemoveIncompleteUploadArgs object encapsulating the bucket, object names
cancellationTokenSystem.Threading.CancellationTokenOptional parameter. Defaults to default(CancellationToken)
Return TypeExceptions
TaskListed Exceptions:
InvalidBucketNameException : upon invalid bucket name
ConnectionException : upon connection error
InternalClientException : upon internal library error

Example

try{// Removes partially uploaded objects from buckets.RemoveIncompleteUploadArgsargs=newRemoveIncompleteUploadArgs().WithBucket(bucketName).WithObject(objectName);awaitminioClient.RemoveIncompleteUploadAsync(args);Console.WriteLine("successfully removed all incomplete upload session of my-bucketname/my-objectname");}catch(MinioExceptione){Console.WriteLine("Error occurred: "+e);}

SelectObjectContentAsync(SelectObjectContentArgs args)

Task<SelectResponseStream> SelectObjectContentAsync(SelectObjectContentArgs args, CancellationToken cancellationToken = default(CancellationToken))

Downloads an object as a stream.

Parameters

ParamTypeDescription
argsSelectObjectContentArgsoptions for SelectObjectContent asyncRequired parameter.
cancellationTokenSystem.Threading.CancellationTokenOptional parameter. Defaults to default(CancellationToken)
Return TypeExceptions
Task: Task callback returns a SelectResponseStream containing select results.Listed Exceptions:
InvalidBucketNameException : upon invalid bucket name.
ConnectionException : upon connection error.
InternalClientException : upon internal library error.
ArgumentException : upon invalid response format
IOException : insufficient data

Example

try{varopts=newSelectObjectOptions(){ExpressionType=QueryExpressionType.SQL,Expression="select count(*) from s3object",InputSerialization=newSelectObjectInputSerialization(){CompressionType=SelectCompressionType.NONE,CSV=newCSVInputOptions(){FileHeaderInfo=CSVFileHeaderInfo.None,RecordDelimiter="\n",FieldDelimiter=",",}},OutputSerialization=newSelectObjectOutputSerialization(){CSV=newCSVOutputOptions(){RecordDelimiter="\n",FieldDelimiter=",",}}};SelectObjectContentArgsargs=SelectObjectContentArgs().WithBucket(bucketName).WithObject(objectName).WithSelectObjectOptions(opts);varresp=awaitminio.SelectObjectContentAsync(args);resp.Payload.CopyTo(Console.OpenStandardOutput());Console.WriteLine("Bytes scanned:"+resp.Stats.BytesScanned);Console.WriteLine("Bytes returned:"+resp.Stats.BytesReturned);Console.WriteLine("Bytes processed:"+resp.Stats.BytesProcessed);if(resp.Progressisnotnull){Console.WriteLine("Progress :"+resp.Progress.BytesProcessed);}}catch(MinioExceptione){Console.WriteLine("Error occurred: "+e);}

SetObjectLegalHoldAsync(SetObjectLegalHoldArgs args)

Task SetObjectLegalHoldAsync(SetObjectLegalHoldArgs args, CancellationToken cancellationToken = default(CancellationToken))

Sets the Legal Hold status of an object.

Parameters

ParamTypeDescription
argsSetObjectLegalHoldArgsSetObjectLegalHoldArgs Argument Object with bucket, object names, version id(optional)
cancellationTokenSystem.Threading.CancellationTokenOptional parameter. Defaults to default(CancellationToken)
Return TypeExceptions
TaskListed Exceptions:
AuthorizationException : upon access or secret key wrong or not found
InvalidBucketNameException : upon invalid bucket name
InvalidObjectNameException : upon invalid object name
BucketNotFoundException : upon bucket with name not found
ObjectNotFoundException : upon object with name not found
MissingObjectLockConfigurationException : upon bucket created with object lock not enabled
MalFormedXMLException : upon configuration XML in http request validation failure

Example

try{// Setting WithLegalHold true, sets Legal hold status to ON.SetObjectLegalHoldArgsargs=newSetObjectLegalHoldArgs().WithBucket(bucketName).WithObject(objectName).WithVersionId(versionId).WithLegalHold(true);awaitminio.SetObjectLegalHoldAsync(args);}catch(MinioExceptione){Console.WriteLine("Error occurred: "+e);}

GetObjectLegalHoldAsync(GetObjectLegalHoldArgs args)

Task<bool> GetObjectLegalHoldAsync(GetObjectLegalHoldArgs args, CancellationToken cancellationToken = default(CancellationToken))

Gets the Legal Hold status of an object.

Parameters

ParamTypeDescription
argsGetObjectLegalHoldArgsGetObjectLegalHoldArgs Argument Object with bucket, object names, version id(optional)
cancellationTokenSystem.Threading.CancellationTokenOptional parameter. Defaults to default(CancellationToken)
Return TypeExceptions
Task<bool>: True if LegalHold is enabled, false otherwise.Listed Exceptions:
AuthorizationException : upon access or secret key wrong or not found
InvalidBucketNameException : upon invalid bucket name
InvalidObjectNameException : upon invalid object name
BucketNotFoundException : upon bucket with name not found
ObjectNotFoundException : upon object with name not found
MissingObjectLockConfigurationException : upon bucket created with object lock not enabled
MalFormedXMLException : upon configuration XML in http request validation failure

Example

try{// Get Legal Hold status a objectvarargs=newGetObjectLegalHoldArgs().WithBucket(bucketName).WithObject(objectName).WithVersionId(versionId);boolenabled=awaitminio.GetObjectLegalHoldAsync(args);Console.WriteLine("LegalHold Configuration STATUS for "+bucketName+"/"+objectName+(!string.IsNullOrEmpty(versionId)?" with Version ID "+versionId:" ")+" : "+(enabled?"ON":"OFF"));}catch(MinioExceptione){Console.WriteLine("Error occurred: "+e);}

SetObjectTagsAsync(SetObjectTagsArgs args)

Task SetObjectTagsAsync(SetObjectTagsArgs args, CancellationToken cancellationToken = default(CancellationToken))

Sets tags to a object.

Parameters

ParamTypeDescription
argsSetObjectTagsArgsSetObjectTagsArgs Argument Object with object, tags to set
cancellationTokenSystem.Threading.CancellationTokenOptional parameter. Defaults to default(CancellationToken)
Return TypeExceptions
TaskListed Exceptions:
AuthorizationException : upon access or secret key wrong or not found
InvalidBucketNameException : upon invalid bucket name
InvalidObjectNameException : upon invalid object name
BucketNotFoundException : upon bucket with name not found
ObjectNotFoundException : upon object with name not found
MalFormedXMLException : upon configuration XML in http request validation failure
UnexpectedMinioException : upon internal errors encountered during the operation

Example

try{// Set Tags for the objectSetObjectTagsArgsargs=newSetObjectTagsArgs().WithBucket(bucketName).WithObject(objectName).WithTagging(tags);awaitminio.SetObjectTagsAsync(args);Console.WriteLine($"Set tags for object {bucketName}/{objectName}.");}catch(MinioExceptione){Console.WriteLine("Error occurred: "+e);}

GetObjectTagsAsync(GetObjectTagsArgs args)

Task<Tagging> GetObjectTagsAsync(GetObjectTagsArgs args, CancellationToken cancellationToken = default(CancellationToken))

Gets tags of a object.

Parameters

ParamTypeDescription
argsGetObjectTagsArgsGetObjectTagsArgs Argument Object with object name
cancellationTokenSystem.Threading.CancellationTokenOptional parameter. Defaults to default(CancellationToken)
Return TypeExceptions
Task<Tagging>: Task object which containing tag-value pairs.Listed Exceptions:
AuthorizationException : upon access or secret key wrong or not found
InvalidBucketNameException : upon invalid bucket name
InvalidObjectNameException : upon invalid object name
BucketNotFoundException : upon bucket with name not found
ObjectNotFoundException : upon object with name not found
MalFormedXMLException : upon configuration XML in http request validation failure
UnexpectedMinioException : upon internal errors encountered during the operation

Example

try{// Get Object Tags for the objectvarargs=newGetObjectTagsArgs().WithBucket(bucketName).WithObject(objectName);vartags=awaitminio.GetObjectTagsAsync(args);Console.WriteLine($"Got tags for object {bucketName}/{objectName}.");}catch(MinioExceptione){Console.WriteLine("Error occurred: "+e);}

RemoveObjectTagsAsync(RemoveObjectTagsArgs args)

Task RemoveObjectTagsAsync(RemoveObjectTagsArgs args, CancellationToken cancellationToken = default(CancellationToken))

Deletes tags of a object.

Parameters

ParamTypeDescription
argsRemoveObjectTagsArgsRemoveObjectTagsArgs Argument Object with object name
cancellationTokenSystem.Threading.CancellationTokenOptional parameter. Defaults to default(CancellationToken)
Return TypeExceptions
TaskListed Exceptions:
AuthorizationException : upon access or secret key wrong or not found
InvalidBucketNameException : upon invalid bucket name
InvalidObjectNameException : upon invalid object name
BucketNotFoundException : upon bucket with name not found
ObjectNotFoundException : upon object with name not found
MalFormedXMLException : upon configuration XML in http request validation failure
UnexpectedMinioException : upon internal errors encountered during the operation

Example

try{// Remove Tags for the objectvarargs=newRemoveObjectTagsArgs().WithBucket(bucketName).WithObject(objectName);awaitminio.RemoveObjectTagsAsync(args);Console.WriteLine($"Removed tags for object {bucketName}/{objectName}.");}catch(MinioExceptione){Console.WriteLine("Error occurred: "+e);}

SetObjectRetentionAsync(SetObjectRetentionArgs args)

Task SetObjectRetentionAsync(SetObjectRetentionArgs args, CancellationToken cancellationToken = default(CancellationToken))

Sets retention configuration to an object.

Parameters

ParamTypeDescription
argsSetObjectRetentionArgsSetObjectRetentionArgs Argument Object with bucket, object names, version id(optional)
cancellationTokenSystem.Threading.CancellationTokenOptional parameter. Defaults to default(CancellationToken)
Return TypeExceptions
TaskListed Exceptions:
AuthorizationException : upon access or secret key wrong or not found
InvalidBucketNameException : upon invalid bucket name
InvalidObjectNameException : upon invalid object name
BucketNotFoundException : upon bucket with name not found
ObjectNotFoundException : upon object with name not found
MissingObjectLockConfigurationException : upon bucket created with object lock not enabled
MalFormedXMLException : upon configuration XML in http request validation failure

Example

try{// Setting Retention Configuration of the object.SetObjectRetentionArgsargs=newSetObjectRetentionArgs().WithBucket(bucketName).WithObject(objectName).WithRetentionValidDays(numOfDays);awaitminio.SetObjectRetentionAsync(args);Console.WriteLine($"Assigned retention configuration to object {bucketName}/{objectName}");}catch(MinioExceptione){Console.WriteLine("Error occurred: "+e);}

GetObjectRetentionAsync(GetObjectRetentionArgs args)

Task<ObjectRetentionConfiguration> GetObjectRetentionAsync(GetObjectRetentionArgs args, CancellationToken cancellationToken = default(CancellationToken))

Gets retention configuration of an object.

Parameters

ParamTypeDescription
argsGetObjectRetentionArgsGetObjectRetentionArgs Argument Object with bucket, object names, version id(optional)
cancellationTokenSystem.Threading.CancellationTokenOptional parameter. Defaults to default(CancellationToken)
Return TypeExceptions
Task<ObjectRetentionConfiguration>: ObjectRetentionConfiguration object with configuration data.Listed Exceptions:
AuthorizationException : upon access or secret key wrong or not found
InvalidBucketNameException : upon invalid bucket name
InvalidObjectNameException : upon invalid object name
BucketNotFoundException : upon bucket with name not found
ObjectNotFoundException : upon object with name not found
MissingObjectLockConfigurationException : upon bucket created with object lock not enabled
MalFormedXMLException : upon configuration XML in http request validation failure

Example

try{// Get Retention configuration of an objectvarargs=newGetObjectRetentionArgs().WithBucket(bucketName).WithObject(objectName);ObjectRetentionConfigurationconfig=awaitminio.GetObjectRetentionAsync(args);Console.WriteLine($"Got retention configuration for object {bucketName}/{objectName}");}catch(MinioExceptione){Console.WriteLine("Error occurred: "+e);}

ClearObjectRetentionAsync(ClearObjectRetentionArgs args)

Task ClearObjectRetentionAsync(ClearObjectRetentionArgs args, CancellationToken cancellationToken = default(CancellationToken))

Clears retention configuration to an object.

Parameters

ParamTypeDescription
argsClearObjectRetentionArgsClearObjectRetentionArgs Argument Object with bucket, object names, version id(optional)
cancellationTokenSystem.Threading.CancellationTokenOptional parameter. Defaults to default(CancellationToken)
Return TypeExceptions
TaskListed Exceptions:
AuthorizationException : upon access or secret key wrong or not found
InvalidBucketNameException : upon invalid bucket name
InvalidObjectNameException : upon invalid object name
BucketNotFoundException : upon bucket with name not found
ObjectNotFoundException : upon object with name not found
MissingObjectLockConfigurationException : upon bucket created with object lock not enabled
MalFormedXMLException : upon configuration XML in http request validation failure

Example

try{// Clearing the Retention Configuration of the object.ClearObjectRetentionArgsargs=newClearObjectRetentionArgs().WithBucket(bucketName).WithObject(objectName);awaitminio.ClearObjectRetentionAsync(args);Console.WriteLine($"Clears retention configuration to object {bucketName}/{objectName}");}catch(MinioExceptione){Console.WriteLine("Error occurred: "+e);}

4. Presigned operations

PresignedGetObjectAsync(PresignedGetObjectArgs args);

Task<string> PresignedGetObjectAsync(PresignedGetObjectArgs args)

Generates a presigned URL for HTTP GET operations. Browsers/Mobile clients may point to this URL to directly download objects even if the bucket is private. This presigned URL can have an associated expiration time in seconds after which it is no longer operational. The default expiry is set to 7 days.

Parameters

ParamTypeDescription
argsPresignedGetObjectArgsPresignedGetObjectArgs encapsulating bucket, object names, expiry, response headers & request date
Return TypeExceptions
Task<string> : string contains URL to download the objectListed Exceptions:
InvalidBucketNameException : upon invalid bucket name
ConnectionException : upon connection error
InvalidExpiryRangeException : upon invalid expiry range.

Example

try{PresignedGetObjectArgsargs=newPresignedGetObjectArgs().WithBucket("mybucket").WithObject("myobject").WithExpiry(60*60*24);Stringurl=awaitminioClient.PresignedGetObjectAsync(args);Console.WriteLine(url);}catch(MinioExceptione){Console.WriteLine("Error occurred: "+e);}

PresignedPutObjectAsync(PresignedPutObjectArgs args)

Task<string> PresignedPutObjectAsync(PresignedPutObjectArgs args)

Generates a presigned URL for HTTP PUT operations. Browsers/Mobile clients may point to this URL to upload objects directly to a bucket even if it is private. This presigned URL can have an associated expiration time in seconds after which it is no longer operational. The default expiry is set to 7 days.

Parameters

ParamTypeDescription
argsPresignedPutObjectArgsPresignedPutObjectArgs arguments object with bucket, object names & expiry
Return TypeExceptions
Task<string> : string contains URL to upload the objectListed Exceptions:
InvalidBucketNameException : upon invalid bucket name
InvalidKeyException : upon an invalid access key or secret key
ConnectionException : upon connection error
InvalidExpiryRangeException : upon invalid expiry range.

Example

try{PresignedPutObjectArgsargs=PresignedPutObjectArgs().WithBucket("mybucket").WithObject("myobject").WithExpiry(60*60*24);Stringurl=awaitminioClient.PresignedPutObjectAsync(args);Console.WriteLine(url);}catch(MinioExceptione){Console.WriteLine("Error occurred: "+e);}

PresignedPostPolicy(PresignedPostPolicyArgs args)

Task<Dictionary<string, string>> PresignedPostPolicyAsync(PresignedPostPolicyArgs args)

Allows setting policy conditions to a presigned URL for POST operations. Policies such as bucket name to receive object uploads, key name prefixes, expiry policy may be set.

Parameters

ParamTypeDescription
argsPresignedPostPolicyArgsPresignedPostPolicyArgs Arguments object includes bucket, object names & Post policy of an object.
Return TypeExceptions
Task<Dictionary<string, string>>: Map of strings to construct form-data.Listed Exceptions:
InvalidBucketNameException : upon invalid bucket name
ConnectionException : upon connection error
NoSuchAlgorithmException : upon requested algorithm was not found during signature calculation.

Example

try{PostPolicypolicy=newPostPolicy();policy.SetContentType("image/png");policy.SetUserMetadata("custom","user");DateTimeexpiration=DateTime.UtcNow;policy.SetExpires(expiration.AddDays(10));policy.SetKey("my-objectname");policy.SetBucket("my-bucketname");PresignedPostPolicyArgsargs=PresignedPostPolicyArgs().WithBucket("my-bucketname").WithObject("my-objectname").WithPolicy(policy);Dictionary<string,string>formData=minioClient.Api.PresignedPostPolicy(args);stringcurlCommand="curl ";foreach(KeyValuePair<string,string>pairinformData){curlCommand=curlCommand+" -F "+pair.Key+"="+pair.Value;}curlCommand=curlCommand+" -F file=@/etc/bashrc https://s3.amazonaws.com/my-bucketname";Console.WriteLine(curlCommand);}catch(MinioExceptione){Console.WriteLine("Error occurred: "+e);}

Client custom settings

SetAppInfo(string appName, string appVersion)

Adds application details to User-Agent.

Parameters

ParamTypeDescription
appNamestringName of the application performing the API requests
appVersionstringVersion of the application performing the API requests

Example

// Set Application name and version to be used in subsequent API requests.minioClient.SetAppInfo("myCloudApp","1.0.0")

SetTraceOn(IRequestLogger logger = null)

Enables HTTP tracing. The trace is written to the stdout.

Parameters

ParamTypeDescription
loggerIRequestLoggerImplementation of interfaceMinio.IRequestLogger for serialization models for trace HTTP

Example

// Set HTTP tracing on with default trace logger.minioClient.SetTraceOn()// Set custom logger for HTTP traceminioClient.SetTraceOn(newJsonNetLogger())

SetTraceOff()

Disables HTTP tracing.

Example

// Sets HTTP tracing off.minioClient.SetTraceOff()
On this page

Page Feedback

Was this page helpful?

Thank you for your feedback!

How can we improve this page?

Optionally provide your email if you would like us to follow up on your feedbackPlease enter a valid email address

Sending feedback...

Failed to send feedback. Please try again.


[8]ページ先頭

©2009-2025 Movatter.jp