Skip to content

How can I implement file upload? #171

@catabozan

Description

@catabozan

I tried to implement file upload into my API, but it seems like although in the tests the files are being sent, they are discarded from the request.
As I understand, it's because the application/vnd.api+json Content-Type does not support file upload.

This is how I send the request from the test files:

$response = $this
    ->jsonApi()
    ->asMultiPartFormData()
    ->withPayload($payload)
    ->post($uri);

And this is the error I get:

Symfony\Component\HttpKernel\Exception\HttpException 

The request entity has a media type which the server or resource does not support.

I guess this is because the Content-Type is not application/vnd.api+json anymore.

I found this issue on how to handle multipart form data on the old cloudcreativity/laravel-json-api repo, but I can't find that method anywhere in the docs (I assume because the issue is from 2019).

What is the best way to implement file upload?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions