/// <summary>
 /// Initializes a new instance of the <see cref="BinaryStorageMetaBase"/> class.
 /// </summary>
 /// <param name="metaBase">The meta base.</param>
 public BinaryStorageMetaBase(BinaryStorageMetaBase metaBase)
     : this(metaBase as BinaryStorageIdentifier)
 {
     if (metaBase != null)
     {
         this.Name = metaBase.Name;
         this.Mime = metaBase.Mime;
         this.Length = metaBase.Length;
         this.Width = metaBase.Width;
         this.Height = metaBase.Height;
         this.Duration = metaBase.Duration;
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Uploads the BLOB by container URI.
        /// </summary>
        /// <param name="containerUri">The container URI.</param>
        /// <param name="blobIdentifier">The BLOB identifier.</param>
        /// <param name="dataBytes">The data bytes.</param>
        /// <param name="meta">The meta.</param>
        /// <param name="metaData">The meta data.</param>
        /// <returns>System.String for ETag.</returns>
        public static string UploadBlobByContainerUri(string containerUri, string blobIdentifier, byte[] dataBytes, BinaryStorageMetaBase meta = null, IDictionary<string, string> metaData = null)
        {
            try
            {
                containerUri.CheckEmptyString("containerUri");
                blobIdentifier.CheckEmptyString("blobIdentifier");

                var container = new CloudBlobContainer(new Uri(containerUri));
                var blob = container.GetBlockBlobReference(blobIdentifier);
                blob.Properties.FillMeta(meta);

                return UploadBlob(blob, dataBytes, metaData);
            }
            catch (Exception ex)
            {
                throw ex.Handle("UploadBlobByContainerUri", new { containerUri, blobIdentifier });
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Uploads the BLOB by BLOB URI.
        /// </summary>
        /// <param name="blobUri">The BLOB URI.</param>
        /// <param name="content">The content.</param>
        /// <param name="encoding">The encoding.</param>
        /// <param name="meta">The meta.</param>
        /// <param name="metaData">The meta data.</param>
        /// <returns>System.String for ETag.</returns>
        public static string UploadBlobByBlobUri(string blobUri, string content, Encoding encoding = null, BinaryStorageMetaBase meta = null, IDictionary<string, string> metaData = null)
        {
            try
            {
                content.CheckEmptyString("content");

                return UploadBlobByBlobUri(blobUri, (encoding ?? Encoding.UTF8).GetBytes(content), meta, metaData);
            }
            catch (Exception ex)
            {
                throw ex.Handle("UploadBlobByBlobUri", ex);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Uploads the BLOB by BLOB URI.
        /// </summary>
        /// <param name="blobUri">The BLOB URI.</param>
        /// <param name="dataBytes">The data bytes.</param>
        /// <param name="meta">The meta.</param>
        /// <param name="metaData">The meta data.</param>
        /// <returns>System.String for ETag.</returns>
        public static string UploadBlobByBlobUri(string blobUri, byte[] dataBytes, BinaryStorageMetaBase meta = null, IDictionary<string, string> metaData = null)
        {
            try
            {
                blobUri.CheckEmptyString("blobUri");

                var blob = new CloudBlockBlob(new Uri(blobUri));
                blob.Properties.FillMeta(meta);

                return UploadBlob(blob, dataBytes, metaData);
            }
            catch (Exception ex)
            {
                throw ex.Handle("UploadBlobByBlobUri", new { blobUri, metaData });
            }
        }
 /// <summary>
 /// Sets the BLOB property.
 /// </summary>
 /// <param name="blobProperties">The BLOB properties.</param>
 /// <param name="meta">The meta.</param>
 public static void FillMeta(this BlobProperties blobProperties, BinaryStorageMetaBase meta)
 {
     if (meta != null && blobProperties != null)
     {
         blobProperties.ContentType = meta.Mime.SafeToString(HttpConstants.ContentType.BinaryDefault);
         blobProperties.ContentDisposition = meta.Name?.ConvertNameToContentDisposition();
     }
 }
 /// <summary>
 /// Sets the BLOB property.
 /// </summary>
 /// <param name="blobProperties">The BLOB properties.</param>
 /// <param name="meta">The meta.</param>
 public static void FillMeta(this BlobProperties blobProperties, BinaryStorageMetaBase meta)
 {
     if (meta != null && blobProperties != null)
     {
         blobProperties.ContentType = meta.Mime;
         blobProperties.ContentDisposition = string.IsNullOrWhiteSpace(meta.Name)
             ? null
             : meta.Name.ToUrlEncodedText();
         blobProperties.ContentDisposition = meta.Name.ConvertNameToContentDisposition();
     }
 }