We got the following code in our controller:
[HttpPost("v1/item/{id}/images")]
public async Task<ActionResult> UploadImage([FromRoute]string Id, [FromForm]IFormFile file)
{
//Upload image logic
}
Local this code works like we expect it to work. When we put this on Azure we get the following response.
{"type":"https://tools.ietf.org/html/rfc7231#section-6.5.1","title":"Bad Request","status":400,"traceId":"|1587f1cc093cd640a1ece0a37a6b33b5.d408b19_"}
It looks like we are not allowed to upload an file this way on Azure. But cannot find any way to make this work.
The project is an .NET Core 2.2 MVC project and it runs on an standaard Azure Web App.
When wanting to use Forms
that have files attached to them (e.g multipart
requests) we can access the request's files using:
Request.Form.Files
which represents the file collection of the incoming form.
The desired file will be read as a stream using the OpenReadStream
method and then deserialized.
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加