//TODO where is the GetBlockBlobReference(uri) api? private CloudBlockBlob GetBlob(DestinationArgs args) { var c = CloudStorageAccount.Parse(_StorageAccountConfig.ConnectionString); var blobClient = new CloudBlobClient(c.BlobStorageUri, c.Credentials); var splits = args.Path.Split("/", StringSplitOptions.RemoveEmptyEntries); if (splits.Length == 0) { throw new InvalidOperationException(); //TODO description } var container = blobClient.GetContainerReference(splits[0]); if (splits.Length == 1) { return(container.GetBlockBlobReference(args.Name)); } var dir = container.GetDirectoryReference(splits[1]); for (var i = 2; i < splits.Length; i++) { dir = dir.GetDirectoryReference(splits[i]); } return(dir.GetBlockBlobReference(args.Name)); }
public async Task <IActionResult> Execute(ReceiveContentArgs content, DestinationArgs destination) { //TODO deeper validation if (content == null || destination == null) { return(new OkResult()); } //This was begging for a Try... var result = await _BlobWriter.Write(content, destination); if (!result.ItemAddedOrOverwritten) { return(new ConflictResult()); } var path = destination.Name.Equals(EndPointNames.ManifestName) ? string.Concat(destination.Path, "/", EndPointNames.ManifestName) : string.Concat(destination.Path, "/", content.PublishingId); var mutable = destination.Name.Equals(EndPointNames.ManifestName); await _QueueSender.Send(new StorageAccountSyncMessage { RelativePath = path, MutableContent = mutable }); return(new OkResult()); }
public async Task <BlobWriterResponse> Write(ReceiveContentArgs content, DestinationArgs destination) { var blob = GetBlob(destination); using var buffer = new MemoryStream(content.SignedContent); return(Write(blob, buffer, content)); //return new BlobWriterResponse {ItemAddedOrOverwritten = true, Uri = blob.Uri}; }