示例#1
0
        public async Task <IActionResult> Upload(IFormCollection formData)
        {
            if (formData == null)
            {
                return(BadRequest());
            }

            try
            {
                if (formData.Files.GetFile("file") != null &&
                    formData.Files.GetFile("file").Length > 0)
                {
                    var isUploadedSuccessfully = await uploadRepository.UploadFile(formData);

                    if (isUploadedSuccessfully == false)
                    {
                        return(BadRequest("This file is already uploaded"));
                    }

                    return(Ok());
                }

                return(BadRequest());
            }
            catch (Exception)
            {
                return(StatusCode(500));
            }
        }