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);
        }
    }
Beispiel #2
0
    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);
        }
    }
    public void BucketDisableVersioning()
    {
        BucketEnableVersioningSample  bucketEnableVersioningSample  = new BucketEnableVersioningSample();
        BucketDisableVersioningSample bucketDisableVersioningSample = new BucketDisableVersioningSample();

        // Versioning is disabled by default, so Enable versioning
        bucketEnableVersioningSample.BucketEnableVersioning(_fixture.BucketNameGeneric);
        _fixture.SleepAfterBucketCreateUpdateDelete();

        // Disable versioning
        var bucket = bucketDisableVersioningSample.BucketDisableVersioning(_fixture.BucketNameGeneric);

        _fixture.SleepAfterBucketCreateUpdateDelete();
        Assert.False(bucket.Versioning.Enabled);
    }
Beispiel #4
0
    public void BucketEnableVersioning()
    {
        BucketEnableVersioningSample  bucketEnableVersioningSample  = new BucketEnableVersioningSample();
        BucketDisableVersioningSample bucketDisableVersioningSample = new BucketDisableVersioningSample();

        // Enable versioning
        var bucket = bucketEnableVersioningSample.BucketEnableVersioning(_fixture.BucketNameGeneric);

        _fixture.SleepAfterBucketCreateUpdateDelete();
        Assert.True(bucket.Versioning.Enabled);

        // Then disable versioning
        bucketDisableVersioningSample.BucketDisableVersioning(_fixture.BucketNameGeneric);
        _fixture.SleepAfterBucketCreateUpdateDelete();
    }