示例#1
0
        public async Task <ActionResult> Upload(HttpPostedFileBase file)
        {
            if (file == null)
            {
                return(RedirectToAction("Index", new { value = "uploadFailure" }));
            }

            try
            {
                var fileExtension = Path.GetExtension(file.FileName);

                var image = await _storageService.AddImageAsync(file.InputStream, fileExtension);

                var faces = await _cognitiveService.UploadAndDetectFaces(image.ImagePath);

                await _storageService.AddMetadataAsync(image, faces);
            }
            catch (Exception e)
            {
                return(RedirectToAction("Index", new { value = "uploadFailure" }));
            }

            return(RedirectToAction("Index", new { value = "uploadSuccess" }));
        }