private void PublishInsight(string authToken, string indexId) { User authUser = new User(authToken); MediaPublish insightPublish = new MediaPublish { PartitionKey = authUser.MediaAccount.Id, RowKey = indexId, MediaAccount = authUser.MediaAccount }; TableClient tableClient = new TableClient(); string tableName = Constant.Storage.Table.InsightPublish; tableClient.UpsertEntity(tableName, insightPublish); }
public void UploadBlock(Stream readStream, string containerName, string directoryPath, string fileName, string partitionKey, int blockIndex, bool lastBlock) { string blockId = Convert.ToBase64String(BitConverter.GetBytes(blockIndex)); CloudBlockBlob blob = GetBlob(containerName, directoryPath, fileName); blob.PutBlock(blockId, readStream, null); string tableName = Constant.Storage.Table.FileUpload; string rowKey = blob.Name; if (blockIndex == 0) { BlockUpload blockUpload = new BlockUpload() { PartitionKey = partitionKey, RowKey = rowKey, BlockIds = new string[] { blockId } }; _tracker.UpsertEntity(tableName, blockUpload); } else { BlockUpload blockUpload = _tracker.GetEntity <BlockUpload>(tableName, partitionKey, rowKey); List <string> blockIds = new List <string>(blockUpload.BlockIds); blockIds.Add(blockId); blockUpload.BlockIds = blockIds.ToArray(); _tracker.UpdateEntity(tableName, blockUpload); } if (lastBlock) { BlockUpload blockUpload = _tracker.GetEntity <BlockUpload>(tableName, partitionKey, rowKey); blob.PutBlockList(blockUpload.BlockIds); _tracker.DeleteEntity(tableName, blockUpload); } }