public void ComposeObject() { UploadFileSample uploadFileSample = new UploadFileSample(); ComposeObjectSample composeObjectSample = new ComposeObjectSample(); DownloadFileSample downloadFileSample = new DownloadFileSample(); var firstObject = "HelloComposeObject.txt"; var secondObject = "HelloComposeObjectAdditional.txt"; var targetObject = "HelloComposedDownload.txt"; uploadFileSample.UploadFile(_fixture.BucketNameGeneric, "Resources/Hello.txt", _fixture.Collect(firstObject)); uploadFileSample.UploadFile(_fixture.BucketNameGeneric, "Resources/HelloDownloadCompleteByteRange.txt", _fixture.Collect(secondObject)); composeObjectSample.ComposeObject(_fixture.BucketNameGeneric, firstObject, secondObject, _fixture.Collect(targetObject)); // Download the composed file downloadFileSample.DownloadFile(_fixture.BucketNameGeneric, targetObject, targetObject); // Content from both file should exists in the downloaded file var targetContent = File.ReadAllText(targetObject); Assert.Contains(File.ReadAllText("Resources/Hello.txt"), targetContent); Assert.Contains(File.ReadAllText("Resources/HelloDownloadCompleteByteRange.txt"), targetContent); File.Delete(targetObject); }
public void DownloadFile() { DownloadFileSample downloadFileSample = new DownloadFileSample(); downloadFileSample.DownloadFile(_fixture.BucketNameGeneric, _fixture.FileName, "Download-test.txt"); Assert.Equal(File.ReadAllText(_fixture.FilePath), File.ReadAllText("Download-test.txt")); File.Delete("Download-test.txt"); }
public void CopyFileArchivedGeneration() { UploadFileSample uploadFileSample = new UploadFileSample(); BucketEnableVersioningSample bucketEnableVersioningSample = new BucketEnableVersioningSample(); GetMetadataSample getMetadataSample = new GetMetadataSample(); DownloadFileSample downloadFileSample = new DownloadFileSample(); CopyFileArchivedGenerationSample copyFileArchivedGenerationSample = new CopyFileArchivedGenerationSample(); DeleteFileArchivedGenerationSample deleteFileArchivedGenerationSample = new DeleteFileArchivedGenerationSample(); BucketDisableVersioningSample bucketDisableVersioningSample = new BucketDisableVersioningSample(); var objectName = "HelloCopyArchive.txt"; var copiedObjectName = "ByeCopy.txt"; // Enable bucket versioning bucketEnableVersioningSample.BucketEnableVersioning(_fixture.BucketNameGeneric); // Uploaded for the first time uploadFileSample.UploadFile(_fixture.BucketNameGeneric, _fixture.FilePath, objectName); // Get generation of first version of the file var obj = getMetadataSample.GetMetadata(_fixture.BucketNameGeneric, objectName); var fileArchivedGeneration = obj.Generation; // Upload again to archive previous generation. uploadFileSample.UploadFile(_fixture.BucketNameGeneric, "Resources/HelloDownloadCompleteByteRange.txt", objectName); // Get generation of second version of the file obj = getMetadataSample.GetMetadata(_fixture.BucketNameGeneric, objectName); var fileCurrentGeneration = obj.Generation; _fixture.CollectArchivedFiles(_fixture.BucketNameGeneric, objectName, fileArchivedGeneration); _fixture.CollectArchivedFiles(_fixture.BucketNameGeneric, objectName, fileCurrentGeneration); try { // Copy first version of the file to new bucket. copyFileArchivedGenerationSample.CopyFileArchivedGeneration(_fixture.BucketNameGeneric, objectName, _fixture.BucketNameRegional, _fixture.CollectRegionalObject(copiedObjectName), fileArchivedGeneration); // Download copied file downloadFileSample.DownloadFile(_fixture.BucketNameRegional, copiedObjectName, copiedObjectName); // Match file contents with first version of the file Assert.Equal(File.ReadAllText(_fixture.FilePath), File.ReadAllText(copiedObjectName)); } finally { File.Delete(copiedObjectName); // Disable bucket versioning bucketDisableVersioningSample.BucketDisableVersioning(_fixture.BucketNameGeneric); } }
public void DeleteFileArchivedGeneration() { UploadFileSample uploadFileSample = new UploadFileSample(); ListFilesSample listFilesSample = new ListFilesSample(); BucketEnableVersioningSample bucketEnableVersioningSample = new BucketEnableVersioningSample(); GetMetadataSample getMetadataSample = new GetMetadataSample(); DownloadFileSample downloadFileSample = new DownloadFileSample(); ListFileArchivedGenerationSample listFileArchivedGenerationSample = new ListFileArchivedGenerationSample(); DeleteFileArchivedGenerationSample deleteFileArchivedGenerationSample = new DeleteFileArchivedGenerationSample(); BucketDisableVersioningSample bucketDisableVersioningSample = new BucketDisableVersioningSample(); var objectName = "HelloDeleteFileArchivedGeneration.txt"; // Enable bucket versioning bucketEnableVersioningSample.BucketEnableVersioning(_fixture.BucketNameGeneric); // Uploaded for the first time uploadFileSample.UploadFile(_fixture.BucketNameGeneric, _fixture.FilePath, objectName); // Upload again to archive previous generation. uploadFileSample.UploadFile(_fixture.BucketNameGeneric, "Resources/HelloDownloadCompleteByteRange.txt", objectName); try { var objects = listFileArchivedGenerationSample.ListFileArchivedGeneration(_fixture.BucketNameGeneric); Assert.Equal(2, objects.Count(a => a.Name == objectName)); // Get Generations var testFiles = objects.Where(a => a.Name == objectName).ToList(); long?fileArchivedGeneration = testFiles[0].Generation; long?fileCurrentGeneration = testFiles[1].Generation; // Delete first generation of the file deleteFileArchivedGenerationSample.DeleteFileArchivedGeneration(_fixture.BucketNameGeneric, objectName, fileArchivedGeneration); objects = listFileArchivedGenerationSample.ListFileArchivedGeneration(_fixture.BucketNameGeneric); Assert.Equal(1, objects.Count(a => a.Name == objectName)); // Delete second generation of the file deleteFileArchivedGenerationSample.DeleteFileArchivedGeneration(_fixture.BucketNameGeneric, objectName, fileCurrentGeneration); objects = listFileArchivedGenerationSample.ListFileArchivedGeneration(_fixture.BucketNameGeneric); Assert.Equal(0, objects.Count(a => a.Name == objectName)); } finally { // Disable bucket versioning bucketDisableVersioningSample.BucketDisableVersioning(_fixture.BucketNameGeneric); } }