.net core API fileupload not working on Azure

C. Molendijk

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.

Bercovici Adrian

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]

編集
0

コメントを追加

0

関連記事

分類Dev

Unit testing fileupload with Moq .net Core

分類Dev

Importing and Deploying .Net Core API to Azure API Managment

分類Dev

API net.core 1.1 の Azure 通知ハブ

分類Dev

.NET Core API LoggerFactory

分類Dev

In Azure Service Fabric, what is the deference between a Stateless Web API and the ASP.NET Core Web API?

分類Dev

.NET CoreのAzure WebJob

分類Dev

Why is my file upload from Angular to .NET core web api not working?

分類Dev

Using Azure Active Directory authentication in ASP.NET Core 2.0 from Web App to Web API

分類Dev

TypeScript API in .NET Core version

分類Dev

.Net Core API method not calling

分類Dev

.net core 2.1 CORS api

分類Dev

Middleware in .net core not working, letting me step into it

分類Dev

Set current working directory on exit (.NET Core)

分類Dev

asp.net core 5.0 RequestSizeLimit not working

分類Dev

Model binding not working in aspnet core web api

分類Dev

.NET Core Azure servicebusqueue number of messages

分類Dev

Using Azure Function (.NET Core) to Download a file

分類Dev

Web api working locally but not when deployed to Azure

分類Dev

REST API を使用して .Net Core Core の Azure Service Bus キューにメッセージを送信する

分類Dev

Azure ServiceBus message from .net core does not parse in .net 4.6.1

分類Dev

.NET Core Web APIキー

分類Dev

ASP.Net Core API Accessing HttpRequestMessage

分類Dev

.Net Core API Returning StreamContent with request object

分類Dev

.NET core web api with queue processing

分類Dev

.NET Core API view model return

分類Dev

SignalR with web Api as client [.Net Core]

分類Dev

Scaling an Azure Elastic Pool with .NET Fluent API

分類Dev

Linq to excel not working , when upgrading .net core 2.1 to .net core 2.2

分類Dev

Browserlink CSS autosync not working ASP.NET Core 2.0

Related 関連記事

  1. 1

    Unit testing fileupload with Moq .net Core

  2. 2

    Importing and Deploying .Net Core API to Azure API Managment

  3. 3

    API net.core 1.1 の Azure 通知ハブ

  4. 4

    .NET Core API LoggerFactory

  5. 5

    In Azure Service Fabric, what is the deference between a Stateless Web API and the ASP.NET Core Web API?

  6. 6

    .NET CoreのAzure WebJob

  7. 7

    Why is my file upload from Angular to .NET core web api not working?

  8. 8

    Using Azure Active Directory authentication in ASP.NET Core 2.0 from Web App to Web API

  9. 9

    TypeScript API in .NET Core version

  10. 10

    .Net Core API method not calling

  11. 11

    .net core 2.1 CORS api

  12. 12

    Middleware in .net core not working, letting me step into it

  13. 13

    Set current working directory on exit (.NET Core)

  14. 14

    asp.net core 5.0 RequestSizeLimit not working

  15. 15

    Model binding not working in aspnet core web api

  16. 16

    .NET Core Azure servicebusqueue number of messages

  17. 17

    Using Azure Function (.NET Core) to Download a file

  18. 18

    Web api working locally but not when deployed to Azure

  19. 19

    REST API を使用して .Net Core Core の Azure Service Bus キューにメッセージを送信する

  20. 20

    Azure ServiceBus message from .net core does not parse in .net 4.6.1

  21. 21

    .NET Core Web APIキー

  22. 22

    ASP.Net Core API Accessing HttpRequestMessage

  23. 23

    .Net Core API Returning StreamContent with request object

  24. 24

    .NET core web api with queue processing

  25. 25

    .NET Core API view model return

  26. 26

    SignalR with web Api as client [.Net Core]

  27. 27

    Scaling an Azure Elastic Pool with .NET Fluent API

  28. 28

    Linq to excel not working , when upgrading .net core 2.1 to .net core 2.2

  29. 29

    Browserlink CSS autosync not working ASP.NET Core 2.0

ホットタグ

アーカイブ