Exemple #1
0
        public string StartCopyFromBlob(IAzureBlockBlob source)
        {
            var standaloneAzureBlockBlob = source as StandaloneAzureBlockBlob;

            if (standaloneAzureBlockBlob == null)
            {
                throw new ArgumentException("Can only copy between blobs in the same hosting environment");
            }

            try
            {
                EnsureBlobDirectoryExists();
                EnsureMetadataDirectoryExists();

                RetryFileOperation(() => File.Copy(standaloneAzureBlockBlob._blobPath, _blobPath, true));
                if (File.Exists(standaloneAzureBlockBlob._metadataPath))
                {
                    RetryFileOperation(() => File.Copy(standaloneAzureBlockBlob._metadataPath, _metadataPath, true));
                }
                else
                {
                    RetryFileOperation(() => File.Delete(_metadataPath));
                }

                CopyState = new StandaloneAzureCopyState(CopyStatus.Success, null);
            }
            catch (IOException ex)
            {
                CopyState = new StandaloneAzureCopyState(CopyStatus.Failed, ex.ToTraceMessage());
            }
            return(Guid.NewGuid().ToString());
        }
        public string StartCopyFromBlob(IAzureBlockBlob source)
        {
            var standaloneAzureBlockBlob = source as StandaloneAzureBlockBlob;
            if (standaloneAzureBlockBlob == null)
            {
                throw new ArgumentException("Can only copy between blobs in the same hosting environment");
            }

            try
            {
                EnsureBlobDirectoryExists();
                EnsureMetadataDirectoryExists();

                RetryFileOperation(() => File.Copy(standaloneAzureBlockBlob._blobPath, _blobPath, true));
                if (File.Exists(standaloneAzureBlockBlob._metadataPath))
                {
                    RetryFileOperation(() => File.Copy(standaloneAzureBlockBlob._metadataPath, _metadataPath, true));
                }
                else
                {
                    RetryFileOperation(() => File.Delete(_metadataPath));
                }

                CopyState = new StandaloneAzureCopyState(CopyStatus.Success, null);
            }
            catch (IOException ex)
            {
                CopyState = new StandaloneAzureCopyState(CopyStatus.Failed, ex.ToTraceMessage());
            }
            return Guid.NewGuid().ToString();
        }