예제 #1
0
        private BlobId ToBlobId(IListBlobItem blob, bool attachMetadata)
        {
            BlobId id;

            if (blob is CloudBlockBlob blockBlob)
            {
                id = new BlobId(blockBlob.Name, BlobItemKind.File);
            }
            else if (blob is CloudAppendBlob appendBlob)
            {
                id = new BlobId(appendBlob.Name, BlobItemKind.File);
            }
            else if (blob is CloudBlobDirectory dirBlob)
            {
                id = new BlobId(dirBlob.Prefix, BlobItemKind.Folder);
            }
            else
            {
                throw new InvalidOperationException($"unknown item type {blob.GetType()}");
            }

            //attach metadata if we can
            if (attachMetadata && blob is CloudBlob cloudBlob)
            {
                id.Meta = AzureUniversalBlobStorageProvider.GetblobMeta(cloudBlob);
            }

            return(id);
        }
예제 #2
0
        private BlobId ToBlobId(IListBlobItem blob, bool attachMetadata)
        {
            BlobId id;

            if (blob is CloudBlockBlob blockBlob)
            {
                string fullName = _prependContainerName
               ? StoragePath.Combine(_container.Name, blockBlob.Name)
               : blockBlob.Name;

                id = new BlobId(fullName, BlobItemKind.File);
            }
            else if (blob is CloudAppendBlob appendBlob)
            {
                string fullName = _prependContainerName
               ? StoragePath.Combine(_container.Name, appendBlob.Name)
               : appendBlob.Name;

                id = new BlobId(fullName, BlobItemKind.File);
            }
            else if (blob is CloudBlobDirectory dirBlob)
            {
                string fullName = _prependContainerName
               ? StoragePath.Combine(_container.Name, dirBlob.Prefix)
               : dirBlob.Prefix;

                id = new BlobId(fullName, BlobItemKind.Folder);
            }
            else
            {
                throw new InvalidOperationException($"unknown item type {blob.GetType()}");
            }

            //attach metadata if we can
            if (attachMetadata && blob is CloudBlob cloudBlob)
            {
                id.Meta = AzureUniversalBlobStorageProvider.GetblobMeta(cloudBlob);
            }

            return(id);
        }