예제 #1
0
        private async Task <Models.File> saveFile(IFormFile uploadedFile)
        {
            var file = new Models.File()
            {
                Name        = Path.GetFileName(uploadedFile.FileName),
                ContentType = uploadedFile.ContentType,
                Length      = uploadedFile.Length
            };

            using (var memoryStream = new MemoryStream())
            {
                await uploadedFile.CopyToAsync(memoryStream);

                file.Content = memoryStream.ToArray();
            }

            return(_formService.AddFile(file));
        }
예제 #2
0
        private async Task <Models.File> saveFile(IFormFile uploadedFile)
        {
            var file = new Models.File()
            {
                Name        = Path.GetFileName(uploadedFile.FileName),
                ContentType = uploadedFile.ContentType,
                Length      = uploadedFile.Length
            };

            using (var memoryStream = new MemoryStream())
            {
                await uploadedFile.CopyToAsync(memoryStream);

                file.Content = memoryStream.ToArray();
            }

            file = _formService.AddFile(file);

            var identity = (ClaimsIdentity)User.Identity;
            await _auditLog.Append(identity.GetClaimAsInt("EmployeeId"), LogActionType.Upload, LogResourceType.File, file.FileId,
                                   $"{identity.GetClaim(ClaimTypes.Name)} uploaded file with id {file.FileId}");

            return(file);
        }