public static UploadPartCopyCommand Create(IServiceClient client, Uri endpoint, ExecutionContext context, UploadPartCopyRequest uploadPartCopyRequest) { OssUtils.CheckBucketName(uploadPartCopyRequest.SourceBucket); OssUtils.CheckObjectKey(uploadPartCopyRequest.SourceKey); OssUtils.CheckBucketName(uploadPartCopyRequest.TargetBucket); OssUtils.CheckObjectKey(uploadPartCopyRequest.TargetKey); if (!uploadPartCopyRequest.PartNumber.HasValue) { throw new ArgumentException("partNumber should be specfied"); } if (!uploadPartCopyRequest.PartSize.HasValue) { throw new ArgumentException("partSize should be specfied"); } if (!uploadPartCopyRequest.BeginIndex.HasValue) { throw new ArgumentException("beginIndex should be specfied"); } if (uploadPartCopyRequest.PartSize < 0 || uploadPartCopyRequest.PartSize > OssUtils.MaxFileSize) { throw new ArgumentException("partSize not live in valid range"); } if (!OssUtils.IsPartNumberInRange(uploadPartCopyRequest.PartNumber)) { throw new ArgumentException("partNumber not live in valid range"); } return(new UploadPartCopyCommand(client, endpoint, context, DeserializerFactory.GetFactory().CreateUploadPartCopyResultDeserializer(uploadPartCopyRequest.PartNumber.Value), uploadPartCopyRequest)); }
public static UploadPartCommand Create(IServiceClient client, Uri endpoint, ExecutionContext context, UploadPartRequest uploadPartRequest) { OssUtils.CheckBucketName(uploadPartRequest.BucketName); OssUtils.CheckObjectKey(uploadPartRequest.Key); if (string.IsNullOrEmpty(uploadPartRequest.UploadId)) { throw new ArgumentException("uploadId should be specified"); } if (!uploadPartRequest.PartNumber.HasValue) { throw new ArgumentException("partNumber should be specified"); } if (!uploadPartRequest.PartSize.HasValue) { throw new ArgumentException("partSize should be specified"); } if (uploadPartRequest.InputStream == null) { throw new ArgumentException("inputStream should be specified"); } if (uploadPartRequest.PartSize < 0 || uploadPartRequest.PartSize > OssUtils.MaxFileSize) { throw new ArgumentException("partSize not live in valid range"); } if (!OssUtils.IsPartNumberInRange(uploadPartRequest.PartNumber)) { throw new ArgumentException("partNumber not live in valid range"); } var conf = OssUtils.GetClientConfiguration(client); var originalStream = uploadPartRequest.InputStream; var streamLength = uploadPartRequest.PartSize.Value; // wrap input stream in PartialWrapperStream originalStream = new PartialWrapperStream(originalStream, streamLength); // setup progress var callback = uploadPartRequest.StreamTransferProgress; if (callback != null) { originalStream = OssUtils.SetupProgressListeners(originalStream, conf.ProgressUpdateInterval, client, callback); uploadPartRequest.InputStream = originalStream; } // wrap input stream in MD5Stream if (conf.EnalbeMD5Check) { var hashStream = new MD5Stream(originalStream, null, streamLength); uploadPartRequest.InputStream = hashStream; context.ResponseHandlers.Add(new MD5DigestCheckHandler(hashStream)); } return(new UploadPartCommand(client, endpoint, context, DeserializerFactory.GetFactory().CreateUploadPartResultDeserializer(uploadPartRequest.PartNumber.Value), uploadPartRequest)); }
public static UploadPartCommand Create(IServiceClient client, Uri endpoint, ExecutionContext context, UploadPartRequest uploadPartRequest) { OssUtils.CheckBucketName(uploadPartRequest.BucketName); OssUtils.CheckObjectKey(uploadPartRequest.Key); if (string.IsNullOrEmpty(uploadPartRequest.UploadId)) { throw new ArgumentException("uploadId should be specified"); } if (!uploadPartRequest.PartNumber.HasValue) { throw new ArgumentException("partNumber should be specified"); } if (!uploadPartRequest.PartSize.HasValue) { throw new ArgumentException("partSize should be specified"); } if (uploadPartRequest.InputStream == null) { throw new ArgumentException("inputStream should be specified"); } if (uploadPartRequest.PartSize < 0 || uploadPartRequest.PartSize > OssUtils.MaxFileSize) { throw new ArgumentException("partSize not live in valid range"); } if (!OssUtils.IsPartNumberInRange(uploadPartRequest.PartNumber)) { throw new ArgumentException("partNumber not live in valid range"); } if (uploadPartRequest.Md5Digest == null && uploadPartRequest.PartSize != null) { uploadPartRequest.Md5Digest = OssUtils.ComputeContentMd5(uploadPartRequest.InputStream, (long)uploadPartRequest.PartSize); } return(new UploadPartCommand(client, endpoint, context, DeserializerFactory.GetFactory().CreateUploadPartResultDeserializer(uploadPartRequest.PartNumber.Value), uploadPartRequest)); }