You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
2.0 KiB

using Amazon;
using Amazon.Runtime;
using Amazon.S3;
using System;
using System.Threading.Tasks;
namespace S3Demo
{
public class Run
{
private static BasicAWSCredentials credentials = new BasicAWSCredentials("admin", "admin123.");
private static string bucketName = "minio/test";
/// <summary>
/// https://docs.aws.amazon.com/sdkfornet/v3/apidocs/items/S3/TS3Config.html
/// https://blog.csdn.net/tw_tangliang/article/details/118669099
/// https://github.com/awsdocs/aws-doc-sdk-examples/blob/main/dotnetv3/S3/UploadFileMPUHighLevelAPIExample/UploadFileMPUHighLevelAPIExample/UploadFileMPUHighLevelAPI.cs
/// </summary>
private static AmazonS3Config conf = new AmazonS3Config()
{
UseHttp = true,
ProxyHost = "http://192.168.60.132",
ProxyPort = 9000,
RegionEndpoint = RegionEndpoint.USEast1
};
public static async Task Main()
{
try
{
//uploaddir
string dirPath = @"C:\Users\song\Pictures\Saved Pictures\";
string suffix = "*.png";
//await UploadDirMPUHighLevelAPI.Uploaderdir(bucketName, dirPath, suffix, credentials, conf);
//uploadfile
string keyName = "360.png";
//await UploadFileMPUHighLevelAPI.Uploaderfile(bucketName, keyName, dirPath, credentials, conf);
//objectTag
string filaPath = @"C:\Users\song\Pictures\Saved Pictures\" + keyName;
String[] tags = new String[] { "SN123456", DateTime.Now.ToString("yyyy-MM-dd'T'HH:mm:sszzz"), "AB023" };
await ObjectTag.Putobjectswithtags(bucketName, keyName, filaPath, tags, credentials, conf);
//getObject
//await GetObject.Readobjectdata(bucketName, keyName, credentials, conf);
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
Console.ReadKey();
}
}
}