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.

59 lines
1.8 KiB

using System;
using S3Demo.Helper;
using Ksat.Supplyment.Library.Uploader;
using Ksat.Logging;
using System.Threading.Tasks;
using Amazon.S3;
using Amazon;
using Amazon.Runtime;
namespace S3Demo.Model.Uploader
{
public class S3UploadRequest : IUploaderRequest<S3UploadModel>
{
// 通过固定域名的方式
//private static AmazonS3Config conf = new AmazonS3Config()
//{
// ServiceURL = "https://play.min.io",
// ForcePathStyle = true
//};
//new BasicAWSCredentials("Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG")
public string bucketName = "minio/test";
public AmazonS3Client client = new AmazonS3Client(new BasicAWSCredentials("admin", "admin123."), new AmazonS3Config()
{
UseHttp = true,
ProxyHost = "http://192.168.60.132",
ProxyPort = 9000,
RegionEndpoint = RegionEndpoint.USEast1
});
private ILogger sLog = LoggerFactory.ForContext<S3UploadOperator>();
public S3UploadModel RequestData { get; set; }
public event UploadFinishHandler UploadFinish;
public void Cancel()
{
mTask?.Dispose();
}
public void Start()
{
_ = objSend();
}
private Task<string> mTask;
public async Task objSend()
{
mTask = ObjectHelper.PutObjectsWithTagsAsync(client, bucketName, RequestData.Keyname, RequestData.Path, RequestData.Tags);
string res = await mTask;
UploadFinish(this, res.Equals("OK"), res);
//TODO: 请求接口,上传状态
Console.WriteLine($"{DateTime.Now.ToString("HH:mm:ss.fff")} s3Recv {RequestData.Keyname} ==>{res}");
}
}
}