public static void PutObjectWithMd5(string bucketName)
{
const string key = "PutObjectWithMd5";
string md5;
using (var fs = File.Open(fileToUpload, FileMode.Open))
{
md5 = OssUtils.ComputeContentMd5(fs, fs.Length);
}
var meta = new ObjectMetadata() { ContentMd5 = md5 };
try
{
client.PutObject(bucketName, key, fileToUpload, meta);
Console.WriteLine("Put object:{0} succeeded", key);
}
catch (OssException ex)
{
Console.WriteLine("Failed with error code: {0}; Error info: {1}. \nRequestID:{2}\tHostID:{3}",
ex.ErrorCode, ex.Message, ex.RequestId, ex.HostId);
}
catch (Exception ex)
{
Console.WriteLine("Failed with error info: {0}", ex.Message);
}
}