```
string accessKey = "minioadmin";
string secretKey = "minioadmin";
string endpoint = "http://127.0.0.1:9000";
string bucketName = "bucket01";
AWSCredentials credentials = new BasicAWSCredentials(accessKey,secretKey);
AmazonS3Config clientConfig = new AmazonS3Config()
{
ServiceURL = endpoint,
UseHttp = true,
SignatureVersion = "2",
ForcePathStyle = true,
SignatureMethod = SigningAlgorithm.HmacSHA1
};
AmazonS3Client s3Client = new AmazonS3Client(credentials, clientConfig);
List<S3Bucket> buckets = s3Client.ListBuckets().Buckets;
if (buckets.Count == 0)
{
PutBucketRequest req = new PutBucketRequest();
req.BucketName = bucketName;
req.UseClientRegion = true;
req.BucketRegionName = "";
s3Client.PutBucket(bucketName);
}
foreach (S3Bucket b in buckets)
{
Console.WriteLine(b.BucketName);
}
string key = "1.png";
PutObjectRequest request = new PutObjectRequest()
{
BucketName = bucketName,
Key = "1.png",
FilePath = @"D:\1.png"
};
s3Client.PutObject(request);
DateTime expire = new DateTime(2100, 1, 1, 0, 0, 0, 0);
GetPreSignedUrlRequest r = new GetPreSignedUrlRequest()
{
Expires = expire,
BucketName = bucketName,
Key = key,
Protocol = Protocol.HTTP
};
string preSignedUrl = s3Client.GetPreSignedURL(r);
Console.WriteLine(preSignedUrl);
```