Skip to content

Instantly share code, notes, and snippets.

@geeksilva97
Last active June 13, 2020 23:15
Show Gist options
  • Save geeksilva97/9a8df492e6d644976df657ca21deb92a to your computer and use it in GitHub Desktop.
Save geeksilva97/9a8df492e6d644976df657ca21deb92a to your computer and use it in GitHub Desktop.
Uploading Files with progress monitoring in VanillaJS, Vue and Angular.
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