21 lines
724 B
C#
Raw Normal View History

2025-01-13 21:06:59 +08:00
using Aliyun.OSS;
using System;
namespace YD_XinWei.Commons.Extend
{
public class ALiOSSHelper
{
public static PutObjectResult Upload(string filename, string decodedString, string accessKeyId, string accessKeySecret, string EndPoint, string bucketName)
{
//创建OssClient实例。
var client = new OssClient(EndPoint, accessKeyId, accessKeySecret);
byte[] buffer = Convert.FromBase64String(decodedString.Split(',')[1]);
System.IO.Stream iStream = new System.IO.MemoryStream(buffer);
// 上传文件。
PutObjectResult result = client.PutObject(bucketName, filename, iStream);
return result;
}
}
}