uploadPart遇到CannotaccessaclosedStream
ReuploadPart遇到CannotaccessaclosedStream
没人用过吗?补充一些http请求的数据
---------------------------------------InitiateMultipartUpload的时候返回的http:-----------------------
HTTP/1.1 200 OK
Date: Fri, 09 Aug 2013 02:21:53 GMT
Content-Type: application/xml
Connection: close
Content-Length: 245
Server: AliyunOSS
x-oss-request-id: 52045241493FCD675E644BCB
bucket-mao-sms1
7c34b682-98dc-4f50-bb40-f16c2ea04aa3
A07DE2D002D64BAF82C2AE1B37F32F0E
--------------------uploadpart 返回的http:-----------------------------------
HTTP/1.1 404 Not Found
Content-Type: application/xml
Connection: close
Content-Length: 380
Date: Fri, 09 Aug 2013 02:22:06 GMT
Server: AliyunOSS
x-oss-request-id: 5204524E49EDCC20189CE806
NoSuchUpload
The specified upload does not exist. The upload ID may be invalid, or the upload may have been aborted or completed.
A07DE2D002D64BAF82C2AE1B37F32F0E
5204524E49EDCC20189CE806
bucket-mao-sms1.oss.aliyuncs.com
-------------------------
ReuploadPart遇到CannotaccessaclosedStream
接到阿里开发的电话,解决了部分问题。在Multipleupload过程中key需要保持不变。
谢谢阿里的及时处理,也希望API文档中能够说明一下。
-------------------------
ReuploadPart遇到CannotaccessaclosedStream
这个是没有问题的代码,希望对以后有需要的人有所帮助。谢谢ali的开发的支持。
static void UploadBig(Bucket bucket, OssClient client)
{
string uploadKey = Guid.NewGuid().ToString();
InitiateMultipartUploadRequest initRequest = new InitiateMultipartUploadRequest(bucket.Name, uploadKey);
var initResult = client.InitiateMultipartUpload(initRequest);
string uploadId = initResult.UploadId;
ConcurrentBag tags = new ConcurrentBag();
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 tasks = new List();
for (long i = 1; i {
UploadPartRequest request = new UploadPartRequest(bucket.Name, uploadKey, 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 t = Task.Factory.StartNew(() =>
{
var upResult = client.UploadPart(request);
tags.Add(upResult.PartETag);
}
);
tasks.Add(t);
}
Task.WaitAll(tasks.ToArray());
}
CompleteMultipartUploadRequest comRequest = new CompleteMultipartUploadRequest (bucket.Name, uploadKey, uploadId);
foreach (var x in tags)
{
comRequest.PartETags.Add(x);
}
var comResult = client.CompleteMultipartUpload(comRequest);
}
赞0
踩0