public string ResolveName(TransferEntry sourceEntry)
        {
            AzureBlobEntry blobEntry = sourceEntry as AzureBlobEntry;
            Debug.Assert(blobEntry != null, "blobEntry");

            return NameResolverHelper.AppendSnapShotTimeToFileName(sourceEntry.RelativePath, blobEntry.Blob.SnapshotTime);
        }
        public string ResolveName(TransferEntry sourceEntry)
        {
            AzureBlobEntry blobEntry = sourceEntry as AzureBlobEntry;

            Debug.Assert(blobEntry != null, "blobEntry");

            return(Utils.AppendSnapShotTimeToFileName(sourceEntry.RelativePath, blobEntry.Blob.SnapshotTime));
        }
 public string ResolveName(TransferEntry sourceEntry)
 {
     if (CrossPlatformHelpers.IsWindows)
     {
         return(sourceEntry.RelativePath.Replace('\\', '/'));
     }
     else
     {
         return(EscapeInvalidCharacters(sourceEntry.RelativePath));
     }
 }
        public string ResolveName(TransferEntry sourceEntry)
        {
            // 1) Unescape original string, original string is UrlEncoded.
            // 2) Replace Azure directory separator with Windows File System directory separator.
            // 3) Trim spaces at the end of the file name.
            string destinationRelativePath = this.TranslateDelimiters(sourceEntry.RelativePath);

            if (Interop.CrossPlatformHelpers.IsWindows)
            {
                destinationRelativePath = destinationRelativePath.TrimEnd(new char[] { ' ' });
            }

            destinationRelativePath = EscapeInvalidCharacters(destinationRelativePath);

            // Split into path + filename parts.
            int lastSlash = destinationRelativePath.LastIndexOf(this.DirSeparator, StringComparison.Ordinal);

            string destinationFileName;
            string destinationPath;

            if (-1 == lastSlash)
            {
                destinationPath     = string.Empty;
                destinationFileName = destinationRelativePath;
            }
            else
            {
                destinationPath     = destinationRelativePath.Substring(0, lastSlash + 1);
                destinationFileName = destinationRelativePath.Substring(lastSlash + 1);
            }

            // Append snapshot time to filename.
            AzureBlobEntry blobEntry = sourceEntry as AzureBlobEntry;

            if (blobEntry != null)
            {
                destinationFileName = Utils.AppendSnapShotTimeToFileName(destinationFileName, blobEntry.Blob.SnapshotTime);
            }

            // Combine path and filename back together again.
            destinationRelativePath = this.CombinePath(destinationPath, destinationFileName);

            return(destinationRelativePath);
        }
        public string ResolveName(TransferEntry sourceEntry)
        {
            // 1) Unescape original string, original string is UrlEncoded.
            // 2) Replace Azure directory separator with Windows File System directory separator.
            // 3) Trim spaces at the end of the file name.
            string destinationRelativePath = EscapeInvalidCharacters(this.TranslateDelimiters(sourceEntry.RelativePath).TrimEnd(new char[] { ' ' }));

            // Split into path + filename parts.
            int lastSlash = destinationRelativePath.LastIndexOf(this.DirSeparator, StringComparison.Ordinal);

            string destinationFileName;
            string destinationPath;

            if (-1 == lastSlash)
            {
                destinationPath = string.Empty;
                destinationFileName = destinationRelativePath;
            }
            else
            {
                destinationPath = destinationRelativePath.Substring(0, lastSlash + 1);
                destinationFileName = destinationRelativePath.Substring(lastSlash + 1);
            }

            // Append snapshot time to filename.
            AzureBlobEntry blobEntry = sourceEntry as AzureBlobEntry;
            if (blobEntry != null)
            {
                destinationFileName = NameResolverHelper.AppendSnapShotTimeToFileName(destinationFileName, blobEntry.Blob.SnapshotTime);
            }

            // Combine path and filename back together again.
            destinationRelativePath = this.CombinePath(destinationPath, destinationFileName);

            return destinationRelativePath;
        }
 protected abstract Transfer CreateTransfer(TransferEntry entry);
 protected override Transfer CreateTransfer(TransferEntry entry)
 {
     TransferLocation sourceLocation = GetSourceTransferLocation(this.Source, entry);
     TransferLocation destLocation = GetDestinationTransferLocation(this.Destination, entry);
     SingleObjectTransfer transfer = new SingleObjectTransfer(sourceLocation, destLocation, this.TransferMethod);
     transfer.Context = this.Context;
     transfer.ContentType = this.ContentType;
     return transfer;
 }
        private TransferLocation GetDestinationTransferLocation(TransferLocation dirLocation, TransferEntry entry)
        {
            string destRelativePath = this.nameResolver.ResolveName(entry);

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

                        AzureBlobEntry sourceBlobEntry = entry as AzureBlobEntry;
                        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);
                        CreateParentDirectoryIfNotExists(file);

                        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);
                        CreateParentDirectoryIfNotExists(path);

                        return new FileLocation(path);
                    }

                default:
                    throw new ArgumentException("TransferLocationType");
            }
        }
        private 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);
                default:
                    throw new ArgumentException("TransferLocationType");
            }
        }