Esempio n. 1
0
        private async Task CreateImage(PhotoEntity photo, Image <SixLabors.ImageSharp.PixelFormats.Rgba32> image)
        {
            using (var outputStream = new MemoryStream())
            {
                Resize(image, 1920);
                image.Save(outputStream, PngFormat.Instance);
                outputStream.Seek(0, SeekOrigin.Begin);

                photo.Url = await _storage.Create(new BlobItem
                {
                    Container = "photos",
                    Stream    = outputStream,
                    Name      = photo.FileName
                });
            }
        }
        public async Task <IActionResult> Post()
        {
            var blob = new BlobObject();

            blob.ReadFileStream(Request);

            var result = await _storage.Create(blob);

            return(Ok(result.SasUri));
        }
Esempio n. 3
0
 public IActionResult Post(BlobItem model)
 {
     if (model.Stream == null)
     {
         if (Request.Form.Files.Count > 0)
         {
             var doc = Request.Form.Files[0];
             model.Stream = doc.OpenReadStream();
         }
     }
     _repo.Create(model).Wait();
     return(Ok());
 }