Exemplo n.º 1
0
        public async Task <string> UploadPhotoAsync(Photo photo)
        {
            var blobService = new AzureBlobService();

            return(await blobService.UploadFileAsync(photo.FileName,
                                                     photo.BinaryContent, photo.ContainerName,
                                                     photo.ContentType));
        }
Exemplo n.º 2
0
        public async Task<IActionResult> Create([Bind("Name,Birthday,Phone,PhotoUrl,Email,Id")] Client client)
        {
            if (ModelState.IsValid)
            {
                client.Id = Guid.NewGuid();
                _context.Add(client);

                //==== Upload da foto do Cliente ====
                for (int i=0; i<Request.Form.Files.Count; i++)
                {
                    var file = Request.Form.Files[i];
                    var blobService = new AzureBlobService();
                    client.PhotoUrl = blobService.UploadFileAsync(file.FileName, file.OpenReadStream(), "clients", file.ContentType).Result;
                }
                //===================================

                await _context.SaveChangesAsync();
                return RedirectToAction(nameof(Index));
            }
            return View(client);
        }