public static void PutObjectFromString(string bucketName)
{
const string key = "PutObjectFromString";
const string str = "Aliyun OSS SDK for C#";
try
{
byte[] binaryData = Encoding.ASCII.GetBytes(str);
var stream = new MemoryStream(binaryData);
client.PutObject(bucketName, key, stream);
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);
}
}