Aliyun OSS SDK for .NET 上线发布
ReAliyunOSSSDKforNET上线发布
示范代码有吗
-------------------------
ReAliyunOSSSDKforNET上线发布
早上研究了下,感觉挺好用。
贴些代码:
const String accessId = '{accessId }'; const String accessKey = '{accessKey}'; const String ossEndpoint = 'http://storage.aliyun.com/'; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) PopulateFiles(); } private void PopulateFiles() { String bucketName = '{BucketName}'; var client = new OssClient(ossEndpoint, accessId, accessKey); var list = client.ListObjects(bucketName); foreach (var f in list.ObjectSummaries) { Response.Write(f.Key ''); } } protected void btnUpload_Click(object sender, EventArgs e) { String bucketName = '{BucketName}'; var client = new OssClient(ossEndpoint, accessId, accessKey); FileInfo fileInfo = new FileInfo(filUpload.PostedFile.FileName); var fileName = fileInfo.Name; ObjectMetadata objectMeta = new ObjectMetadata(); objectMeta.ContentType = 'image/jpeg'; client.PutObject(bucketName, fileName, filUpload.FileContent, objectMeta); PopulateFiles(); }
赞0
踩0