代码如下,亲有何建议?
static void UploadBig(Bucket bucket, OssClient client)
{
InitiateMultipartUploadRequest initRequest = new InitiateMultipartUploadRequest (bucket.Name, Guid.NewGuid().ToString());
var initResult = client.InitiateMultipartUpload(initRequest);
string uploadId = initResult.UploadId;
List<PartETag> tags = new List<PartETag> ();
using (FileStream fs = File.OpenRead(@"E:\work\Database\surveyMPSDB_Demo-Full Database Backup.bak"))
{
long partCount = 6*1024*1024;
long count = fs.Length % partCount == 0 ? fs.Length / partCount : fs.Length / partCount 1;
List<Task> tasks = new List<Task>();
for (long i = 1; i <= count; i)
{
UploadPartRequest request = new UploadPartRequest(bucket.Name, Guid.NewGuid().ToString(), uploadId);
Byte[] content = new Byte[partCount];
int readCount = fs.Read(content, 0, (int)partCount);
MemoryStream stream = new MemoryStream (content, 0, readCount);
stream.Seek(0, SeekOrigin.Begin);
request.InputStream = stream;
request.PartNumber = (int)i;
request.PartSize = readCount;
var upResult = client.UploadPart(request);
tags.Add(upResult.PartETag);
//var t = Task.Factory.StartNew(() =>
//{
//}
//);
//tasks.Add(t);
}
//Task.WaitAll(tasks.ToArray());
}
CompleteMultipartUploadRequest comRequest = new CompleteMultipartUploadRequest (bucket.Name, Guid.NewGuid().ToString(), uploadId);
var comResult = client.CompleteMultipartUpload(comRequest);
}
-------------------------
-------------------------
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。