public static void ClassInitialize() { //get a OSS client object _ossClient = OssClientFactory.CreateOssClient(); //get current class name, which is prefix of bucket/object _className = TestContext.CurrentContext.Test.FullName; _className = _className.Substring(_className.LastIndexOf('.') + 1).ToLowerInvariant(); //create the bucket _bucketName = OssTestUtils.GetBucketName(_className); _ossClient.CreateBucket(_bucketName); //upload sample object as source object _sourceObjectKey = OssTestUtils.GetObjectKey(_className); var metadata = new ObjectMetadata(); var poResult = OssTestUtils.UploadObject(_ossClient, _bucketName, _sourceObjectKey, Config.UploadSampleFile, metadata); _sourceObjectETag = poResult.ETag; //upload multipart sample object as source object _sourceBigObjectKey = _sourceObjectKey + ".js"; metadata = new ObjectMetadata(); poResult = OssTestUtils.UploadObject(_ossClient, _bucketName, _sourceBigObjectKey, Config.MultiUploadSampleFile, metadata); _sourceBigObjectETag = poResult.ETag; }
public void ResumableDownloadSmallFileWithMd5CheckTest() { var targetFile = OssTestUtils.GetTargetFileName(_className); targetFile = Path.Combine(Config.DownloadFolder, targetFile); var config = new ClientConfiguration(); config.EnalbeMD5Check = true; var client = OssClientFactory.CreateOssClient(config); try { DownloadObjectRequest request = new DownloadObjectRequest(_bucketName, _objectKey, targetFile); var metadata = client.ResumableDownloadObject(request); var expectedETag = metadata.ETag; var downloadedFileETag = FileUtils.ComputeContentMd5(targetFile); Assert.AreEqual(expectedETag.ToLowerInvariant(), downloadedFileETag.ToLowerInvariant()); } finally { try { FileUtils.DeleteFile(targetFile); } catch (Exception e) { LogUtility.LogWarning("Delete file {0} failed with Exception {1}", targetFile, e.Message); } } }
public void ResumableDownloadBigFileSingleThreadTest() { var targetFile = OssTestUtils.GetTargetFileName(_className); targetFile = Path.Combine(Config.DownloadFolder, targetFile); var key = OssTestUtils.GetObjectKey(_className); _ossClient.PutObject(_bucketName, key, Config.MultiUploadTestFile); var config = new ClientConfiguration(); var client = OssClientFactory.CreateOssClient(config); try { DownloadObjectRequest request = new DownloadObjectRequest(_bucketName, key, targetFile); request.CheckpointDir = Config.DownloadFolder; request.ParallelThreadCount = 1; var metadata = client.ResumableDownloadObject(request); var expectedETag = metadata.ETag; var downloadedFileETag = FileUtils.ComputeContentMd5(targetFile); Assert.AreEqual(expectedETag.ToLowerInvariant(), downloadedFileETag.ToLowerInvariant()); } finally { try { FileUtils.DeleteFile(targetFile); } catch (Exception e) { LogUtility.LogWarning("Delete file {0} failed with Exception {1}", targetFile, e.Message); } _ossClient.DeleteObject(_bucketName, key); } }
public void CreateBucketWithDuplicatedNameDifferentLocationTest() { //get a random bucketName var bucketName = OssTestUtils.GetBucketName(_className); var settings = AccountSettings.Load(); //point to location (Beijing) other than Hangzhou settings.OssEndpoint = Config.SecondEndpoint; var ossSecondClient = OssClientFactory.CreateOssClient(settings); //create the bucket _ossClient.CreateBucket(bucketName); try { //TODO: due to 5596363, user can see buckets in all regions, though only specify one region //assert bucket does not exist //Assert.IsFalse(OssTestUtils.BucketExists(ossSecondClient, bucketName)); Assert.IsTrue(OssTestUtils.BucketExists(ossSecondClient, bucketName)); //try to create bucket with same name on different location ossSecondClient.CreateBucket(bucketName); Assert.Fail("Bucket creation should be failed with dup name and different location"); } catch (OssException e) { Assert.AreEqual(OssErrorCode.BucketAlreadyExists, e.ErrorCode); } finally { _ossClient.DeleteBucket(bucketName); } }
public void ResumableUploadObjectTestWithSingleThread() { var key = OssTestUtils.GetObjectKey(_className); try { var fileInfo = new FileInfo(Config.MultiUploadTestFile); var fileSize = fileInfo.Length; var config = new ClientConfiguration(); var client = OssClientFactory.CreateOssClient(config); UploadObjectRequest request = new UploadObjectRequest(_bucketName, key, Config.MultiUploadTestFile); request.Metadata = new ObjectMetadata(); request.CheckpointDir = Config.DownloadFolder; request.PartSize = fileSize / 3; request.ParallelThreadCount = 1; var result = client.ResumableUploadObject(request); Assert.IsTrue(OssTestUtils.ObjectExists(_ossClient, _bucketName, key)); Assert.IsTrue(result.ETag.Length > 0); } finally { if (OssTestUtils.ObjectExists(_ossClient, _bucketName, key)) { _ossClient.DeleteObject(_bucketName, key); } } }
public static void ClassInitialize() { //get a OSS client object _ossClient = OssClientFactory.CreateOssClient(); _ossPayerClient = new OssClient(Config.Endpoint, Config.PayerAccessKeyId, Config.PayerAccessKeySecret); //get current class name, which is prefix of bucket/object _className = TestContext.CurrentContext.Test.FullName; _className = _className.Substring(_className.LastIndexOf('.') + 1).ToLowerInvariant(); //create the bucket _bucketName = OssTestUtils.GetBucketName(_className); _ossClient.CreateBucket(_bucketName); string policy = "{\"Version\":\"1\",\"Statement\":[{\"Action\":[\"oss:*\"],\"Effect\": \"Allow\"," + "\"Principal\":[\"" + Config.PayerUid + "\"]," + "\"Resource\": [\"acs:oss:*:*:" + _bucketName + "\",\"acs:oss:*:*:" + _bucketName + "/*\"]}]}"; _ossClient.SetBucketPolicy(new SetBucketPolicyRequest(_bucketName, policy)); _ossClient.SetBucketRequestPayment(new SetBucketRequestPaymentRequest(_bucketName, RequestPayer.Requester)); _archiveBucketName = _bucketName + "archive"; _ossClient.CreateBucket(_bucketName); _ossClient.CreateBucket(_archiveBucketName, StorageClass.Archive); policy = "{\"Version\":\"1\",\"Statement\":[{\"Action\":[\"oss:*\"],\"Effect\": \"Allow\"," + "\"Principal\":[\"" + Config.PayerUid + "\"]," + "\"Resource\": [\"acs:oss:*:*:" + _archiveBucketName + "\",\"acs:oss:*:*:" + _archiveBucketName + "/*\"]}]}"; _ossClient.SetBucketPolicy(new SetBucketPolicyRequest(_archiveBucketName, policy)); _ossClient.SetBucketRequestPayment(new SetBucketRequestPaymentRequest(_archiveBucketName, RequestPayer.Requester)); }
public void CreateAndDeleteBucketSecondRegionTest() { var settings = AccountSettings.Load(); //point to region (Beijing) other than Hangzhou settings.OssEndpoint = Config.SecondEndpoint; var ossClient = OssClientFactory.CreateOssClient(settings); //get a random bucketName var bucketName = OssTestUtils.GetBucketName(_className); //assert bucket does not exist Assert.IsFalse(OssTestUtils.BucketExists(ossClient, bucketName), string.Format("Bucket {0} should not exist before creation", bucketName)); //create a new bucket ossClient.CreateBucket(bucketName); OssTestUtils.WaitForCacheExpire(); Assert.IsTrue(OssTestUtils.BucketExists(ossClient, bucketName), string.Format("Bucket {0} should exist after creation", bucketName)); //delete the bucket ossClient.DeleteBucket(bucketName); OssTestUtils.WaitForCacheExpire(); Assert.IsFalse(OssTestUtils.BucketExists(ossClient, bucketName), string.Format("Bucket {0} should not exist after deletion", bucketName)); }
private static void RunTest(string name, int numberOfConcurrency, int fileSize, bool isUniqueOssClient) { var doneEvents = new List <ManualResetEvent>(); var prepareFileThreads = new List <PrepareFileThread>(); for (int i = 0; i < numberOfConcurrency; i++) { var resetEvent = new ManualResetEvent(false); doneEvents.Add(resetEvent); var fileName = Path.Combine(Config.DownloadFolder, string.Format("{0}_{1}", name, i)); var threadWrapper = new PrepareFileThread(fileName, fileSize, doneEvents[i]); prepareFileThreads.Add(threadWrapper); ThreadPool.QueueUserWorkItem(threadWrapper.ThreadPoolCallback, i); } WaitHandle.WaitAll(doneEvents.ToArray()); doneEvents.Clear(); prepareFileThreads.Clear(); var objectOperateThreads = new List <ObjectOperateThread>(); for (int i = 0; i < numberOfConcurrency; i++) { var resetEvent = new ManualResetEvent(false); doneEvents.Add(resetEvent); var fileName = Path.Combine(Config.DownloadFolder, string.Format("{0}_{1}", name, i)); var client = isUniqueOssClient ? _ossClient : OssClientFactory.CreateOssClient(); var threadWrapper = new ObjectOperateThread(client, fileName, i, doneEvents[i]); objectOperateThreads.Add(threadWrapper); ThreadPool.QueueUserWorkItem(threadWrapper.ThreadPoolCallback, i); } WaitHandle.WaitAll(doneEvents.ToArray()); doneEvents.Clear(); objectOperateThreads.Clear(); }
public void ResumableDownloadBigFileWithMultipartUploadWithMd5CheckTest() { var targetFile = OssTestUtils.GetTargetFileName(_className); targetFile = Path.Combine(Config.DownloadFolder, targetFile); var key = OssTestUtils.GetObjectKey(_className); _ossClient.ResumableUploadObject(_bucketName, key, Config.MultiUploadTestFile, new ObjectMetadata(), Config.DownloadFolder, null); try { var config = new ClientConfiguration(); config.EnalbeMD5Check = true; var client = OssClientFactory.CreateOssClient(config); DownloadObjectRequest request = new DownloadObjectRequest(_bucketName, key, targetFile); var metadata = client.ResumableDownloadObject(request); Assert.AreEqual(metadata.ContentLength, new FileInfo(targetFile).Length); } finally { try { FileUtils.DeleteFile(targetFile); } catch (Exception e) { LogUtility.LogWarning("Delete file {0} failed with Exception {1}", targetFile, e.Message); } _ossClient.DeleteObject(_bucketName, key); } }
public void MultipartUploadComplexStepTestWithoutCrc() { Common.ClientConfiguration config = new Common.ClientConfiguration(); config.EnableCrcCheck = false; IOss ossClient = OssClientFactory.CreateOssClient(config); MultipartUploadComplexStepTest(ossClient); }
public static void ClassInitialize() { //get a OSS client object _ossClient = OssClientFactory.CreateOssClient(); //prefix of bucket name used in current test class _className = TestContext.CurrentContext.Test.FullName; _className = _className.Substring(_className.LastIndexOf('.') + 1).ToLowerInvariant(); }
public static void ClassInitialize() { //get current class name, which is prefix of bucket/object _className = TestContext.CurrentContext.Test.FullName; _className = _className.Substring(_className.LastIndexOf('.') + 1).ToLowerInvariant(); _ossClient = OssClientFactory.CreateOssClient(); _bucketName = OssTestUtils.GetBucketName(_className); _ossClient.CreateBucket(_bucketName); }
public static void ClassInitialize() { //get a OSS client object _ossClient = OssClientFactory.CreateOssClient(); //create the bucket _bucketName = OssTestUtils.GetBucketName("bucket-inventory"); _bucketName2 = _bucketName + "-dest"; _ossClient.CreateBucket(_bucketName); _ossClient.CreateBucket(_bucketName2); }
public static void ClassInitialize() { //get a OSS client object _ossClient = OssClientFactory.CreateOssClient(); _className = TestContext.CurrentContext.Test.FullName; _className = _className.Substring(_className.LastIndexOf('.') + 1).ToLowerInvariant(); //create the bucket _bucketName = OssTestUtils.GetBucketName(_className); _ossClient.CreateBucket(_bucketName); }
public void ResumableDownloadBigFileSingleThreadBreakAndResumeTest() { var targetFile = OssTestUtils.GetTargetFileName(_className); targetFile = Path.Combine(Config.DownloadFolder, targetFile); var key = OssTestUtils.GetObjectKey(_className); _ossClient.PutObject(_bucketName, key, Config.MultiUploadTestFile); bool progressUpdateCalled = false; bool faultInjected = false; try { DownloadObjectRequest request = new DownloadObjectRequest(_bucketName, key, targetFile); request.PartSize = 100 * 1024; request.CheckpointDir = Config.DownloadFolder; request.StreamTransferProgress += (object sender, StreamTransferProgressArgs e) => { if (!progressUpdateCalled) { progressUpdateCalled = true; } else { if (!faultInjected) { faultInjected = true; throw new TimeoutException("Inject failure"); } } }; var config = new ClientConfiguration(); request.ParallelThreadCount = 1; var client = OssClientFactory.CreateOssClient(config); var metadata = client.ResumableDownloadObject(request); var expectedETag = metadata.ETag; var downloadedFileETag = FileUtils.ComputeContentMd5(targetFile); Assert.AreEqual(expectedETag.ToLowerInvariant(), downloadedFileETag.ToLowerInvariant()); Assert.AreEqual(progressUpdateCalled, true); } finally { try { FileUtils.DeleteFile(targetFile); } catch (Exception e) { LogUtility.LogWarning("Delete file {0} failed with Exception {1}", targetFile, e.Message); } _ossClient.DeleteObject(_bucketName, key); } }
public void ResumableDownloadBigFileSingleThreadWithProgressUpdateTest() { var targetFile = OssTestUtils.GetTargetFileName(_className); targetFile = Path.Combine(Config.DownloadFolder, targetFile); var key = OssTestUtils.GetObjectKey(_className); _ossClient.PutObject(_bucketName, key, Config.MultiUploadTestFile); bool progressUpdateCalled = false; int percentDone = 0; long totalBytesDownloaded = 0; var config = new ClientConfiguration(); config.EnalbeMD5Check = true; var client = OssClientFactory.CreateOssClient(config); try { DownloadObjectRequest request = new DownloadObjectRequest(_bucketName, key, targetFile); request.ParallelThreadCount = 1; request.StreamTransferProgress += (object sender, StreamTransferProgressArgs e) => { totalBytesDownloaded += e.TransferredBytes; Console.WriteLine("TotalBytes:" + e.TotalBytes); Console.WriteLine("TransferredBytes:" + e.TransferredBytes); Console.WriteLine("PercentageDone:" + e.PercentDone); progressUpdateCalled = true; percentDone = e.PercentDone; }; var metadata = client.ResumableDownloadObject(request); var expectedETag = metadata.ETag; var downloadedFileETag = FileUtils.ComputeContentMd5(targetFile); Assert.AreEqual(expectedETag.ToLowerInvariant(), downloadedFileETag.ToLowerInvariant()); Assert.AreEqual(progressUpdateCalled, true); Assert.AreEqual(percentDone, 100); } finally { try { FileUtils.DeleteFile(targetFile); } catch (Exception e) { LogUtility.LogWarning("Delete file {0} failed with Exception {1}", targetFile, e.Message); } _ossClient.DeleteObject(_bucketName, key); } }
public static void ClassInitialize() { _config = new ClientConfiguration(); //get a OSS client object _ossClient = OssClientFactory.CreateOssClient(_config); //get current class name, which is prefix of bucket/object _className = TestContext.CurrentContext.Test.FullName; _className = _className.Substring(_className.LastIndexOf('.') + 1).ToLowerInvariant(); //create the bucket _bucketName = OssTestUtils.GetBucketName(_className); _ossClient.CreateBucket(_bucketName); //create sample object _objectKey = OssTestUtils.GetObjectKey(_className); OssTestUtils.UploadObject(_ossClient, _bucketName, _objectKey, Config.UploadTestFile, new ObjectMetadata()); }
public static void ClassInitialize() { //get a OSS client object _ossClient = OssClientFactory.CreateOssClient(); //get current class name, which is prefix of bucket/object _className = TestContext.CurrentContext.Test.FullName; _className = _className.Substring(_className.LastIndexOf('.') + 1).ToLowerInvariant(); //create the bucket _bucketName = OssTestUtils.GetBucketName(_className); _ossClient.CreateBucket(_bucketName); //upload sample object _objectKey = OssTestUtils.GetObjectKey(_className); //upload multipart sample object _bigObjectKey = _objectKey + ".js"; // temporary local file _tmpLocalFile = _className + ".tmp"; }
public static void ClassInitialize() { //get a OSS client object _ossClient = OssClientFactory.CreateOssClient(); //get current class name, which is prefix of bucket/object _className = TestContext.CurrentContext.Test.FullName; _className = _className.Substring(_className.LastIndexOf('.') + 1).ToLowerInvariant(); //create the bucket _bucketName = OssTestUtils.GetBucketName(_className); _ossClient.CreateBucket(_bucketName); //create sample object _keyName = OssTestUtils.GetObjectKey(_className); _keyName += ".jpg"; _process = "image/resize,m_fixed,w_100,h_100"; _localImageFile = Config.ImageTestFile; _processedKey = "process/image" + _keyName; _imageInfo = "{\n \"FileSize\": {\"value\": \"5470\"},\n \"Format\": {\"value\": \"jpg\"},\n \"ImageHeight\": {\"value\": \"100\"},\n \"ImageWidth\": {\"value\": \"100\"},\n \"ResolutionUnit\": {\"value\": \"1\"},\n \"XResolution\": {\"value\": \"1/1\"},\n \"YResolution\": {\"value\": \"1/1\"}}"; }
public static void ClassInitialize() { //get a OSS client object _ossClient = OssClientFactory.CreateOssClient(); //get current class name, which is prefix of bucket/object _className = TestContext.CurrentContext.Test.FullName; _className = _className.Substring(_className.LastIndexOf('.') + 1).ToLowerInvariant(); //create the bucket _bucketName = OssTestUtils.GetBucketName(_className); _ossClient.CreateBucket(_bucketName); //create sample object _keyName = OssTestUtils.GetObjectKey(_className); _sqlMessage = "name,school,company,age\r\n" + "Lora Francis,School A,Staples Inc,27\r\n" + "Eleanor Little,School B,\"Conectiv, Inc\",43\r\n" + "Rosie Hughes,School C,Western Gas Resources Inc,44\r\n" + "Lawrence Ross,School D,MetLife Inc.,24"; _jsonMessage = "{\n" + "\t\"name\": \"Lora Francis\",\n" + "\t\"age\": 27,\n" + "\t\"company\": \"Staples Inc\"\n" + "}\n" + "{\n" + "\t\"name\": \"Eleanor Little\",\n" + "\t\"age\": 43,\n" + "\t\"company\": \"Conectiv, Inc\"\n" + "}\n" + "{\n" + "\t\"name\": \"Rosie Hughes\",\n" + "\t\"age\": 44,\n" + "\t\"company\": \"Western Gas Resources Inc\"\n" + "}\n" + "{\n" + "\t\"name\": \"Lawrence Ross\",\n" + "\t\"age\": 24,\n" + "\t\"company\": \"MetLife Inc.\"\n" + "}"; _test_csv_file = Path.Combine(Config.DownloadFolder, "sample_data.csv"); _test_csv_gzip_file = Path.Combine(Config.DownloadFolder, "sample_data.csv.gz"); }
public static void ClassInitialize() { //get a OSS client object _ossClient = OssClientFactory.CreateOssClient(); //get current class name, which is prefix of bucket/object _className = TestContext.CurrentContext.Test.FullName; _className = _className.Substring(_className.LastIndexOf('.') + 1).ToLowerInvariant(); //create the bucket _bucketName = OssTestUtils.GetBucketName(_className); _ossClient.CreateBucket(_bucketName); //upload sample object _objectKey = OssTestUtils.GetObjectKey(_className); //upload multipart sample object _bigObjectKey = _objectKey + ".js"; // call paramters _callbackUrl = Config.CallbackServer; _callbackBody = "bucket=${bucket}&object=${object}&etag=${etag}&size=${size}&mimeType=${mimeType}&my_var1=${x:var1}"; _callbackOkResponse = "{\"Status\":\"OK\"}"; }
public void PutObjectWithPreSignedUriWithoutCrc() { var testStr = FileUtils.GenerateOneKb(); var bytes = Encoding.ASCII.GetBytes(testStr); var now = DateTime.Now; //set expiration time to 5 seconds later var expireDate = now.AddSeconds(5); var targetObject = OssTestUtils.GetObjectKey(_className); var uri = _ossClient.GeneratePresignedUri(_bucketName, targetObject, expireDate, SignHttpMethod.Put); try { Common.ClientConfiguration config = new Common.ClientConfiguration(); config.EnableCrcCheck = false; IOss ossClient = OssClientFactory.CreateOssClient(config); var putResult = ossClient.PutObject(uri, new MemoryStream(bytes)); Assert.AreEqual(putResult.HttpStatusCode, HttpStatusCode.OK); } catch (WebException ex) { Assert.Fail(ex.ToString()); } }
public static void ClassCleanup() { var client = OssClientFactory.CreateOssClient(); OssTestUtils.CleanBucket(client, _bucketName); }
private static void RunTest(string name, int numberOfConcurrency, int fileSize, bool isUniqueOssClient) { var allTasks = new List <Task>(); for (var i = 0; i < numberOfConcurrency; i++) { var fileName = string.Format("{0}_{1}", name, i); fileName = Path.Combine(Config.UploadSampleFolder, fileName); var task = Task.Factory.StartNew(() => FileUtils.PrepareSampleFile(fileName, fileSize)); allTasks.Add(task); } Task.WaitAll(allTasks.ToArray()); allTasks.Clear(); for (var i = 0; i < numberOfConcurrency; i++) { var fileName = string.Format("{0}_{1}", name, i); fileName = Path.Combine(Config.UploadSampleFolder, fileName); var index = i; var task = Task.Factory.StartNew(() => PutAndGetObject( isUniqueOssClient ? _ossClient : OssClientFactory.CreateOssClient(), fileName, index)); allTasks.Add(task); } Task.WaitAll(allTasks.ToArray()); }
public void TestDisableCrc() { Common.ClientConfiguration config = new Common.ClientConfiguration(); config.EnableCrcCheck = false; IOss ossClient = OssClientFactory.CreateOssClient(config); var targetFile = OssTestUtils.GetTargetFileName(_className); targetFile = Path.Combine(Config.DownloadFolder, targetFile); var objectKeyName = "test-object-disable-crc"; try { // put & get PutObjectResult putObjectResult = ossClient.PutObject(_bucketName, objectKeyName, Config.UploadTestFile); var actualCrc = putObjectResult.ResponseMetadata[HttpHeaders.HashCrc64Ecma]; OssObject ossObject = ossClient.GetObject(_bucketName, objectKeyName); var expectedCrc = OssUtils.ComputeContentCrc64(ossObject.Content, ossObject.ContentLength); Assert.AreEqual(expectedCrc, actualCrc); ossClient.DeleteObject(_bucketName, objectKeyName); // put & get by uri var testStr = FileUtils.GenerateOneKb(); var content = Encoding.ASCII.GetBytes(testStr); var now = DateTime.Now; var expireDate = now.AddSeconds(120); var uri = _ossClient.GeneratePresignedUri(_bucketName, objectKeyName, expireDate, SignHttpMethod.Put); var putResult = ossClient.PutObject(uri, new MemoryStream(content)); expectedCrc = putResult.ResponseMetadata[HttpHeaders.HashCrc64Ecma]; actualCrc = OssUtils.ComputeContentCrc64(new MemoryStream(content), content.Length); Assert.AreEqual(expectedCrc, actualCrc); uri = _ossClient.GeneratePresignedUri(_bucketName, objectKeyName, expireDate, SignHttpMethod.Get); ossObject = ossClient.GetObject(uri); expectedCrc = OssUtils.ComputeContentCrc64(ossObject.Content, ossObject.ContentLength); Assert.AreEqual(expectedCrc, actualCrc); ossClient.DeleteObject(_bucketName, objectKeyName); // upload & download var uploadObjectResult = ossClient.ResumableUploadObject(_bucketName, objectKeyName, Config.MultiUploadTestFile, null, Config.DownloadFolder); actualCrc = uploadObjectResult.ResponseMetadata[HttpHeaders.HashCrc64Ecma]; DownloadObjectRequest downloadObjectRequest = new DownloadObjectRequest(_bucketName, objectKeyName, targetFile); var metadata = ossClient.ResumableDownloadObject(downloadObjectRequest); Assert.AreEqual(metadata.Crc64, actualCrc); ossClient.DeleteObject(_bucketName, objectKeyName); // append using (var fs = File.Open(Config.UploadTestFile, FileMode.Open)) { var fileLength = fs.Length; var appendObjectRequest = new AppendObjectRequest(_bucketName, objectKeyName) { Content = fs, }; var appendObjectResult = _ossClient.AppendObject(appendObjectRequest); fs.Seek(0, SeekOrigin.Begin); actualCrc = OssUtils.ComputeContentCrc64(fs, fs.Length); Assert.AreEqual(appendObjectResult.HashCrc64Ecma.ToString(), actualCrc); ossClient.DeleteObject(_bucketName, objectKeyName); } } finally { try { FileUtils.DeleteFile(targetFile); } catch (Exception e) { LogUtility.LogWarning("Delete file {0} failed with Exception {1}", targetFile, e.Message); } } }