コード例 #1
0
        public async Task <IActionResult> IndexAsync()
        {
            if (HttpContext.Request.Form.Files != null)
            {
                var files = HttpContext.Request.Form.Files;
                foreach (var file in files)
                {
                    if (file.Length > 0)
                    {
                        var result = await BlobManager.AddImageAsync(file.FileName, file);

                        if (result.Successfull)
                        {
                        }
                    }
                }
            }

            /*CosmosManager.ImageDataCollection.InsertOne(new ImageDataModel
             * {
             *  FileName = file.FileName,
             *  FileSize = int.Parse(file.Length.ToString()),
             *  FileType = file.ContentType,
             *  ImageUrl = (String) result.Payload,
             *  LastModified = DateTime.Now.ToString()
             * }); ;
             * }
             * }
             * }
             * }
             * var mongoCollection = CosmosManager.ImageDataCollection;
             * var findResult = CosmosManager.ImageDataCollection.Find(e => e.Id != null).ToList();
             * return View(findResult);*/
            return(View());
        }
コード例 #2
0
        public async Task <IActionResult> SaveImage(IFormFile organizationImage)
        {
            if (HttpContext.Request.Form.Files != null)
            {
                var files  = HttpContext.Request.Form.Files;
                var result = await BlobManager.AddImageAsync(organizationImage.FileName, organizationImage);

                var payload = result.Payload;
                var user    = await _userManager.GetUserAsync(User);

                var orga = _parteiDbContext.Organizations.Single(x => x.Id == user.OrgranizationId);
                orga.OrganizationImage = payload.ToString();
                _parteiDbContext.SaveChanges();
            }
            return(RedirectToAction("Index"));
        }