Example #1
0
        public async Task <IActionResult> PostDocument(IFormFile file)
        {
            if (!_documentService.FileWithinLimit(file.Length))
            {
                return(BadRequest("File is to large"));
            }

            if (!_documentService.CheckExtension(Path.GetExtension(file.FileName).Substring(1).ToLower()))
            {
                return(BadRequest("Wrong file extension"));
            }

            var documentId = await _documentService.Create(file, CancellationToken.None);

            return(Created(nameof(GetDocument), new { documentId }));
        }