Ejemplo n.º 1
0
        protected static TransferLocation GetSourceTransferLocation(TransferLocation dirLocation, TransferEntry entry)
        {
            switch (dirLocation.Type)
            {
            case TransferLocationType.AzureBlobDirectory:
                AzureBlobDirectoryLocation azureBlobDirLocation = dirLocation as AzureBlobDirectoryLocation;
                AzureBlobEntry             azureBlobEntry       = entry as AzureBlobEntry;

                AzureBlobLocation azureBlobLocation = new AzureBlobLocation(azureBlobEntry.Blob);
                azureBlobLocation.BlobRequestOptions = azureBlobDirLocation.BlobRequestOptions;

                return(azureBlobLocation);

            case TransferLocationType.AzureFileDirectory:
                AzureFileDirectoryLocation azureFileDirLocation = dirLocation as AzureFileDirectoryLocation;
                AzureFileEntry             azureFileEntry       = entry as AzureFileEntry;

                AzureFileLocation azureFileLocation = new AzureFileLocation(azureFileEntry.File);
                azureFileLocation.FileRequestOptions = azureFileDirLocation.FileRequestOptions;

                return(azureFileLocation);

            case TransferLocationType.LocalDirectory:
                FileEntry fileEntry = entry as FileEntry;

                return(new FileLocation(fileEntry.FullPath, fileEntry.RelativePath));

            default:
                throw new ArgumentException("TransferLocationType");
            }
        }
Ejemplo n.º 2
0
        protected TransferLocation GetDestinationTransferLocation(TransferLocation dirLocation, TransferEntry entry)
        {
            string destRelativePath = this.nameResolver.ResolveName(entry);

            AzureBlobEntry sourceBlobEntry = entry as AzureBlobEntry;

            switch (dirLocation.Type)
            {
            case TransferLocationType.AzureBlobDirectory:
            {
                AzureBlobDirectoryLocation blobDirLocation = dirLocation as AzureBlobDirectoryLocation;
                BlobType destBlobType = this.BlobType;

                if (sourceBlobEntry != null)
                {
                    // if source is Azure blob storage, source and destination blob share the same blob type
                    destBlobType = sourceBlobEntry.Blob.BlobType;
                }

                CloudBlob blob = null;
                switch (destBlobType)
                {
                case Blob.BlobType.BlockBlob:
                case Blob.BlobType.Unspecified:
                    blob = blobDirLocation.BlobDirectory.GetBlockBlobReference(destRelativePath);
                    break;

                case Blob.BlobType.PageBlob:
                    blob = blobDirLocation.BlobDirectory.GetPageBlobReference(destRelativePath);
                    break;

                case Blob.BlobType.AppendBlob:
                    blob = blobDirLocation.BlobDirectory.GetAppendBlobReference(destRelativePath);
                    break;
                }

                AzureBlobLocation retLocation = new AzureBlobLocation(blob);
                retLocation.BlobRequestOptions = blobDirLocation.BlobRequestOptions;
                return(retLocation);
            }

            case TransferLocationType.AzureFileDirectory:
            {
                AzureFileDirectoryLocation fileDirLocation = dirLocation as AzureFileDirectoryLocation;
                CloudFile file = fileDirLocation.FileDirectory.GetFileReference(destRelativePath);

                AzureFileLocation retLocation = new AzureFileLocation(file);
                retLocation.FileRequestOptions = fileDirLocation.FileRequestOptions;
                return(retLocation);
            }

            case TransferLocationType.LocalDirectory:
            {
                DirectoryLocation localDirLocation = dirLocation as DirectoryLocation;
                string            path             = Path.Combine(localDirLocation.DirectoryPath, destRelativePath);

                return(new FileLocation(path, destRelativePath));
            }

            default:
                throw new ArgumentException("TransferLocationType");
            }
        }