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());
        }
コード例 #2
0
        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};
        }
コード例 #3
0
        private byte[] MapSignedContent(BinaryContentResponse bcr)
        {
            var args = new ReceiveContentArgs
            {
                LastModified  = bcr.LastModified,
                SignedContent = bcr.SignedContent,
                PublishingId  = bcr.PublishingId,
            };
            var argsString = _JsonSerializer.Serialize(args);

            return(Encoding.UTF8.GetBytes(argsString));
        }
 public async Task <IActionResult> HttpPostEks([FromBody] ReceiveContentArgs args, [FromServices] HttpPostContentReciever2 command)
 => await command.Execute(args, new DestinationArgs { Path = _ContentPathProvider.ExposureKeySet, Name = args.PublishingId });
 public async Task <IActionResult> HttpPostCalcConfig([FromBody] ReceiveContentArgs args, [FromServices] HttpPostContentReciever2 command)
 => await command.Execute(args, new DestinationArgs { Path = _ContentPathProvider.RiskCalculationParameters, Name = args.PublishingId });
        public async Task <IActionResult> HttpPostManifest([FromBody] ReceiveContentArgs args, [FromServices] ManifestBlobWriter blobWriter, [FromServices] IQueueSender <StorageAccountSyncMessage> qSender)
        {
            var command = new HttpPostContentReciever2(blobWriter, qSender);

            return(await command.Execute(args, new DestinationArgs { Path = _ContentPathProvider.Manifest, Name = EndPointNames.ManifestName }));
        }
コード例 #7
0
 protected abstract BlobWriterResponse Write(CloudBlockBlob blob, MemoryStream buffer, ReceiveContentArgs content);
コード例 #8
0
        protected override BlobWriterResponse Write(CloudBlockBlob blob, MemoryStream input, ReceiveContentArgs content)
        {
            blob.Properties.ContentType  = MediaTypeNames.Application.Zip;
            blob.Properties.CacheControl = "immutable;max-age=31536000"; //TODO hard coded 1 year.
            try
            {
                blob.UploadFromStream(input, AccessCondition.GenerateIfNotExistsCondition());
                return(new BlobWriterResponse {
                    Uri = blob.Uri, ItemAddedOrOverwritten = true
                });
            }
            catch (StorageException e)
            {
                if (e.RequestInformation.HttpStatusCode == 409)
                {
                    return new BlobWriterResponse {
                               Uri = blob.Uri, ItemAddedOrOverwritten = false
                    }
                }
                ;

                throw;
            }
        }
    }
コード例 #9
0
 protected override BlobWriterResponse Write(CloudBlockBlob blob, MemoryStream input, ReceiveContentArgs content)
 {
     blob.Properties.ContentType  = MediaTypeNames.Application.Zip;
     blob.Properties.CacheControl = "max-age=14400"; //TODO hard coded 4 hours.
     blob.UploadFromStream(input);                   //NB want to accept ANY change
     return(new BlobWriterResponse {
         Uri = blob.Uri, ItemAddedOrOverwritten = true
     });
 }