Ejemplo n.º 1
0
        protected override byte[] LoadDocument(BiblosDS.Library.Common.Objects.Document Document)
        {
            if (string.IsNullOrEmpty(Document.Storage.AuthenticationKey))
            {
                Document.Storage = StorageService.GetStorage(Document.Storage.IdStorage);
            }


            StorageAccountInfo account = StorageAccountInfo.GetAccountInfoFromConfiguration(
                string.Empty,
                Document.Storage.MainPath,
                Document.Storage.AuthenticationKey,
                true);

            BlobStorage blobStorage = BlobStorage.Create(account);

            blobStorage.RetryPolicy = RetryPolicies.RetryN(2, TimeSpan.FromMilliseconds(100));

            //Check if exist storage area
            //If exist put the storage in the configured path
            if (!string.IsNullOrEmpty(Document.StorageArea.Path))
            {
                container = blobStorage.GetBlobContainer(Document.Storage.Name.ToLower() + Document.StorageArea.Path.ToLower());
            }
            else
            {
                container = blobStorage.GetBlobContainer(Document.Storage.Name.ToLower());
            }

            BlobContents   contents = new BlobContents(new MemoryStream());
            BlobProperties blob     = container.GetBlob(GetFileName(Document), contents, false);

            return(contents.AsBytes());
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Gets the blob contents and properties if the blob has not been modified since the time specified.
 /// Use this method if you have cached the contents of a blob and want to avoid retrieving the blob
 /// if it has not changed since the last time you retrieved it.
 /// </summary>
 /// <param name="blobProperties">The properties of the blob obtained from an earlier call to GetBlob. This
 /// parameter is updated by the call if the blob has been modified</param>
 /// <param name="blobContents">Contains the stream to which the contents of the blob are written if it has been
 /// modified</param>
 /// <param name="transferAsChunks">Should the blob be gotten in pieces. This requires more round-trips, but will retry smaller pieces in case of failure.</param>
 /// <returns>true if the blob has been modified, false otherwise</returns>
 public abstract bool GetBlobIfModified(BlobProperties blobProperties, BlobContents blobContents, bool transferAsChunks);
Ejemplo n.º 3
0
 /// <summary>
 /// Get the blob contents and properties if the blob exists
 /// </summary>
 /// <param name="name">The name of the blob</param>
 /// <param name="blobContents">Object in which the contents are returned.
 /// This object should contain a writable stream or should be a default constructed object.</param>
 /// <param name="transferAsChunks">Should the blob be gotten in pieces. This requires more round-trips, but will retry smaller pieces in case of failure.</param>
 /// <returns>The properties of the blob if the blob exists.</returns>
 public abstract BlobProperties GetBlob(string name, BlobContents blobContents, bool transferAsChunks);
Ejemplo n.º 4
0
 /// <summary>
 /// Updates an existing blob if it has not been modified since the specified time which is typically
 /// the last modified time of the blob when you retrieved it.
 /// Use this method to implement optimistic concurrency by avoiding clobbering changes to the blob
 /// made by another writer.
 /// </summary>
 /// <param name="blob">The properties of the blob. This object should be one previously
 /// obtained from a call to GetBlob or GetBlobProperties and have its LastModifiedTime property set.</param>
 /// <param name="contents">The contents of the blob. The contents of the blob should be readable</param>
 /// <returns>true if the blob was updated. false if the blob has changed since the last time</returns>
 /// <remarks>The LastModifiedTime property of <paramref name="blob"/> is set as a result of this call.
 /// This method also has an effect on the ETag values that are managed by the service if the update was
 /// successful.</remarks>
 public abstract bool UpdateBlobIfNotModified(BlobProperties blob, BlobContents contents);
Ejemplo n.º 5
0
 /// <summary>
 /// Create a new blob or overwrite an existing blob.
 /// </summary>
 /// <param name="blobProperties">The properties of the blob</param>
 /// <param name="blobContents">The contents of the blob</param>
 /// <param name="overwrite">Should this request overwrite an existing blob ?</param>
 /// <returns>true if the blob was created. false if the blob already exists and <paramref name="overwrite"/>was set to false</returns>
 /// <remarks>The LastModifiedTime property of <paramref name="blobProperties"/> is set as a result of this call.
 /// This method also has an effect on the ETag values that are managed by the service.</remarks>
 public abstract bool CreateBlob(BlobProperties blobProperties, BlobContents blobContents, bool overwrite);