Last active
June 13, 2020 23:15
-
-
Save geeksilva97/9a8df492e6d644976df657ca21deb92a to your computer and use it in GitHub Desktop.
Uploading Files with progress monitoring in VanillaJS, Vue and Angular.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Threading.Tasks; | |
using Microsoft.AspNetCore.Http; | |
using Microsoft.AspNetCore.Mvc; | |
using Microsoft.Extensions.Logging; | |
namespace UploadAPI.Controllers | |
{ | |
[ApiController] | |
[Route("[controller]")] | |
public class ProfileController : ControllerBase | |
{ | |
[HttpPost("upload")] | |
[Produces("application/json")] | |
[DisableRequestSizeLimit] // this line is only to test with long files | |
public ActionResult<string> UploadFile( | |
[FromForm(Name = "file")] IFormFile file | |
) { | |
if(file == null) { | |
return Ok(); | |
} | |
return Ok(new { | |
message = "Uploaded", | |
file = new { | |
name = file.Name, | |
filename = file.FileName, | |
type = file.ContentType, | |
} | |
}); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment