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;
3 years ago
using S3Demo.Helper;
using Ksat.Supplyment.Library.Uploader;
using Ksat.Logging;
3 years ago
using System.Threading.Tasks;
using Amazon.S3;
using Amazon;
using Amazon.Runtime;
namespace S3Demo.Model.Uploader
{
3 years ago
public class S3UploadRequest : IUploaderRequest<S3UploadModel>
{
3 years ago
// 通过固定域名的方式
//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>();
3 years ago
public S3UploadModel RequestData { get; set; }
public event UploadFinishHandler UploadFinish;
public void Cancel()
{
3 years ago
mTask?.Dispose();
}
public void Start()
{
3 years ago
_ = objSend();
}
private Task<string> mTask;
public async Task objSend()
{
3 years ago
mTask = ObjectHelper.PutObjectsWithTagsAsync(client, bucketName, RequestData.Keyname, RequestData.Path, RequestData.Tags);
3 years ago
string res = await mTask;
UploadFinish(this, res.Equals("OK"), res);
//TODO: 请求接口,上传状态
Console.WriteLine($"{DateTime.Now.ToString("HH:mm:ss.fff")} s3Recv {RequestData.Keyname} ==>{res}");
}
}
}