private static void AsyncUploadPartCopys(String targetBucket, String targetObject, String sourceBucket, String sourceObject, String uploadId, int partSize) { var metadata = client.GetObjectMetadata(sourceBucket, sourceObject); var fileSize = metadata.ContentLength; var partCount = (int)fileSize / partSize; if (fileSize % partSize != 0) { partCount++; } var ctx = new UploadPartCopyContext() { TargetBucket = targetBucket, TargetObject = targetObject, UploadId = uploadId, TotalParts = partCount, CompletedParts = 0, SyncLock = new object(), PartETags = new List <PartETag>(), WaitEvent = new ManualResetEvent(false) }; for (var i = 0; i < partCount; i++) { var skipBytes = (long)partSize * i; var size = (partSize < fileSize - skipBytes) ? partSize : (fileSize - skipBytes); var request = new UploadPartCopyRequest(targetBucket, targetObject, sourceBucket, sourceObject, uploadId) { PartSize = size, PartNumber = i + 1, BeginIndex = skipBytes }; client.BeginUploadPartCopy(request, UploadPartCopyCallback, new UploadPartCopyContextWrapper(ctx, i + 1)); } ctx.WaitEvent.WaitOne(); }
private static void AsyncUploadPartCopys(String targetBucket, String targetObject, String sourceBucket, String sourceObject, String uploadId, int partSize) { var metadata = _ossClient.GetObjectMetadata(sourceBucket, sourceObject); var fileSize = metadata.ContentLength; var partCount = (int)fileSize / partSize; if (fileSize % partSize != 0) { partCount++; } var ctx = new UploadPartCopyContext() { TargetBucket = targetBucket, TargetObject = targetObject, UploadId = uploadId, TotalParts = partCount, CompletedParts = 0, SyncLock = new object(), PartETags = new List<PartETag>(), WaitEvent = new ManualResetEvent(false) }; for (var i = 0; i < partCount; i++) { var skipBytes = (long)partSize * i; var size = (partSize < fileSize - skipBytes) ? partSize : (fileSize - skipBytes); var request = new UploadPartCopyRequest(targetBucket, targetObject, sourceBucket, sourceObject, uploadId) { PartSize = size, PartNumber = i + 1, BeginIndex = skipBytes }; _ossClient.BeginUploadPartCopy(request, UploadPartCopyCallback, new UploadPartCopyContextWrapper(ctx, i + 1)); } ctx.WaitEvent.WaitOne(); }
public UploadPartCopyContextWrapper(UploadPartCopyContext context, int partNumber) { Context = context; PartNumber = partNumber; }
public UploadPartCopyContextWrapper(UploadPartCopyContext context, int partNumber) { Context = context; PartNumber = partNumber; }