コード例 #1
0
        private async Task UploadTagToBlob(TagEntity tag, string tagName, string content, string contentType)
        {
            var container = await this.ConnectAsync();

            var blob = container.GetBlockBlobReference(tagName);

            blob.Properties.ContentType = contentType;
            blob.Metadata.Add("id", tag.TagId);
            blob.Metadata.Add("uid", tag.Uid);
            blob.Metadata.Add("version", tag.Version);
            blob.Metadata.Add("revision", tag.Revision);

            // TODO: it would be nice if we could pre-gzip our tags in storage but that requires the client to accept
            //       gzip which not enough people seem to do.
            //blob.Properties.ContentEncoding = "gzip";
            //using (var stream = new MemoryStream(bytes.Length))
            //{
            //    using (var gzip = new GZipStream(stream, CompressionLevel.Optimal, true))
            //    {
            //        gzip.Write(bytes, 0, bytes.Length);
            //    }

            //    stream.Seek(0, SeekOrigin.Begin);
            //    blob.UploadFromStream(stream);
            //}

            var bytes = Encoding.UTF8.GetBytes(content);

            await blob.UploadFromByteArrayAsync(bytes, 0, bytes.Length);
        }
コード例 #2
0
        public async Task <TagEntity> GetPrimaryTagAsync(TagEntity tag)
        {
            var partitionKey = TagEntity.CalculatePartitionKey(tag.Channel);

            var rowKey = TagEntity.CalculateRowKey(true, tag.Alias, tag.Media, tag.Version, tag.Revision);

            var op = TableOperation.Retrieve <TagEntity>(partitionKey, rowKey);

            var result = await this.Table.ExecuteAsync(op);

            return((TagEntity)result.Result);
        }
コード例 #3
0
        public TagEntity AsPrimary()
        {
            var tag = new TagEntity
            {
                PartitionKey = this.PartitionKey,
                RowKey       = CalculateRowKey(true, this.Alias, this.Media, this.Version, this.Revision),
                Channel      = this.Channel,
                Alias        = this.Alias,
                Description  = this.Description,
                Keywords     = this.Keywords,
                LogoUri      = this.LogoUri,
                Media        = this.Media,
                Name         = this.Name,
                Revision     = this.Revision,
                Stored       = this.Stored,
                TagId        = this.TagId,
                Version      = this.Version
            };

            return(tag);
        }
コード例 #4
0
 public async Task UploadXmlTag(TagEntity tagEntity, string tagContent)
 {
     await UploadTagToBlob(tagEntity, tagEntity.XmlBlobName, tagContent, "application/swid-tag+xml");
 }
コード例 #5
0
 public async Task UploadJsonTag(TagEntity tagEntity, string tagContent)
 {
     await UploadTagToBlob(tagEntity, tagEntity.JsonBlobName, tagContent, "application/swid-tag+json");
 }