public UploadableIndexedBlob(string fileName, Stream stream, string fileKey, IndexedBlobEntity indexedBlobEntity, IndexedBlobStorageOptions options, CloudIndexedBlobStore cloudIndexedBlobStore, Dictionary <string, string> properties)
     : base(fileKey, indexedBlobEntity, options, cloudIndexedBlobStore, properties)
 {
     Length   = stream.Length;
     _stream  = stream;
     FileName = fileName;
 }
Пример #2
0
 public CopyableIndexedBlob(CloudBlockBlob sourceBlob, string fileKey, IndexedBlobEntity entity, IndexedBlobStorageOptions options, CloudIndexedBlobStore cloudIndexedBlobStore, Dictionary <string, string> properties)
     : base(fileKey, entity, options, cloudIndexedBlobStore, properties)
 {
     _sourceBlob = sourceBlob;
     if (sourceBlob.Properties.Length == 0)
     {
         sourceBlob.FetchAttributes();
     }
     Length   = sourceBlob.Properties.Length;
     FileName = sourceBlob.Name;
 }
Пример #3
0
 protected CloudIndexedBlob(string fileKey, IndexedBlobEntity entity, IndexedBlobStorageOptions options, CloudIndexedBlobStore cloudIndexedBlobStore, Dictionary <string, string> properties)
 {
     _properties    = properties != null ? new Dictionary <string, string>(properties) : new Dictionary <string, string>();
     FileKey        = fileKey;
     Exists         = entity != null;
     _blobCount     = entity != null ? entity.BlobCount : options.AdditionalBlobsForLoadBalancing + 1;
     Length         = entity != null ? entity.Length : 0;
     _propertyCount = entity != null ? entity.PropertyCount : _properties.Count;
     Options        = options;
     Store          = cloudIndexedBlobStore;
 }
        public DownloadUploadImportBlob(CloudBlockBlob sourceBlob, string fileKey, IndexedBlobEntity indexRecord, IndexedBlobStorageOptions options, CloudIndexedBlobStore store, Dictionary <string, string> properties)
            : base(fileKey, indexRecord, options, store, properties)
        {
            _sourceBlob = sourceBlob;

            if (sourceBlob.Properties.Length == 0)
            {
                sourceBlob.FetchAttributes();
            }
            Length   = sourceBlob.Properties.Length;
            FileName = sourceBlob.Name;
        }
Пример #5
0
        void InsertIndex()
        {
            var indexRecord = new IndexedBlobEntity
            {
                PartitionKey  = FileKey,
                RowKey        = FileKey,
                BlobUri       = Blob.Uri.ToString(),
                BlobCount     = _blobCount,
                Length        = Length,
                FileName      = FileName,
                PropertyCount = _propertyCount
            };

            try
            {
                var batch = new TableBatchOperation
                {
                    TableOperation.Insert(indexRecord)
                };

                if (_properties.Count > 0)
                {
                    var dynamicTableEntity = new DynamicTableEntity(FileKey, string.Format("prop::{0}", FileKey));
                    foreach (var property in _properties)
                    {
                        dynamicTableEntity.Properties.Add(property.Key, new EntityProperty(property.Value));
                    }
                    batch.Add(TableOperation.Insert(dynamicTableEntity));
                }
                Store.Table.ExecuteBatch(batch);
                Exists = true;
            }
            catch (StorageException storageException)
            {
                if (storageException.RequestInformation.HttpStatusCode == (int)HttpStatusCode.Conflict)
                {
                    Exists = true;
                    throw new BlobAlreadyExistsException(FileKey);
                }
                throw;
            }
        }