asp.netOSS的问题
Reasp.netOSS的问题
亲,给你个C#的示例:
public static void PutObject(string key, string fileName)
{
try
{
string bucketName = BucketName;
string fileToUpload = fileName;
OssClient ossClient = new OssClient(new Uri('http://oss.aliyuncs.com/'), accessId, accessKey,);
ObjectMetadata metadata = new ObjectMetadata();
metadata.UserMetadata.Add('myfield1', 'test1');
FileStream fs = null;
try
{
fs = File.Open(fileToUpload, FileMode.Open);
PutObjectResult result = ossClient.PutObject(bucketName, key, fs, metadata);
}
catch (Exception ex)
{
if (fs != null)
{
fs.Close();
}
}
}
catch (Exception e) { throw e; }
}
赞0
踩0