Skip to content

docs(file-upload): move from core to symfony and update #2094

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion admin/file-upload.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Handling File Upload

If you need to handle the file upload in the server part, please follow [the related documentation](../core/file-upload.md).
If you need to handle the file upload in the server part, please follow [the related documentation](../symfony/file-upload.md).

This documentation assumes you have a `/media_objects` endpoint accepting `multipart/form-data`-encoded data.

Expand Down
9 changes: 5 additions & 4 deletions core/graphql.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ composer require api-platform/graphql
You can now use GraphQL at the endpoint: `https://localhost:8443/graphql`.

> [!NOTE]
> If you used [the Symfony Variant thanks to Symfony Flex](../symfony/index.md#installing-the-framework)
> or the Laravel variant, URLs will be prefixed with `/api` by default. For example, the GraphQL endpoint will be: `https://localhost:8443/api/graphql`.
> If you used [the Symfony Variant thanks to Symfony Flex](../symfony/index.md#installing-the-framework) or the Laravel
> variant, URLs will be prefixed with `/api` by default. For example, the GraphQL endpoint will be: `https://localhost:8443/api/graphql`.

## Changing Location of the GraphQL Endpoint

Expand Down Expand Up @@ -2830,9 +2830,10 @@ Since the command prints the schema to the output if you don't use the `-o` opti
bin/console api:graphql:export > path/in/host/schema.graphql
```

## Handling File Upload
## Handling File Upload with Symfony

Please follow the [file upload documentation](file-upload.md), only the differences will be documented here.
If you use Symfony, please follow the [file upload documentation](../symfony/file-upload.md), only the differences
will be documented here.

The file upload with GraphQL follows the [GraphQL multipart request specification](https://github.com/jaydenseric/graphql-multipart-request-spec).

Expand Down
2 changes: 1 addition & 1 deletion outline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ chapters:
- nelmio-api-doc
- user
- jwt
- file-upload
- title: "API Platform for Laravel"
path: laravel
items:
Expand Down Expand Up @@ -65,7 +66,6 @@ chapters:
- elasticsearch
- controllers
- events
- file-upload
- jwt
- form-data
- bootstrap
Expand Down
21 changes: 10 additions & 11 deletions core/file-upload.md → symfony/file-upload.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# Handling File Upload

As common a problem as it may seem, handling file upload requires a custom
implementation in your app. This page will guide you in handling file upload in
your API, with the help of
[VichUploaderBundle](https://github.com/dustin10/VichUploaderBundle). It is
recommended you [read the documentation of
VichUploaderBundle](https://github.com/dustin10/VichUploaderBundle/blob/master/docs/index.md)
# Handling File Upload with Symfony

As common a problem as it may seem, handling file upload requires a custom implementation in your app. This page will
guide you in handling file upload in your API, with the help of[VichUploaderBundle](https://github.com/dustin10/VichUploaderBundle).
It is recommended you [read the documentation of VichUploaderBundle](https://github.com/dustin10/VichUploaderBundle/blob/master/docs/index.md)
before proceeding. It will help you get a grasp on how the bundle works, and why we use it.

**Note**: Uploading files won't work in `PUT` or `PATCH` requests, you must use `POST` method to upload files.
See [the related issue on Symfony](https://github.com/symfony/symfony/issues/9226) and [the related bug in PHP](https://bugs.php.net/bug.php?id=55815) talking about this behavior.
> [!NOTE]
> Uploading files won't work in `PUT` or `PATCH` requests, you must use `POST` method to upload files.
> See [the related issue on Symfony](https://github.com/symfony/symfony/issues/9226) and
> [the related bug in PHP](https://bugs.php.net/bug.php?id=55815) talking about this behavior.

Enable the multipart format globally in order to use it as the input format of your resource:

Expand Down Expand Up @@ -137,7 +136,7 @@ Note: From V3.3 onwards, `'multipart/form-data'` must either be including in the
Returning the plain file path on the filesystem where the file is stored is not useful for the client, which needs a
URL to work with.

A [normalizer](serialization.md#normalization) could be used to set the `contentUrl` property:
A [normalizer](../core/serialization.md#normalization) could be used to set the `contentUrl` property:

```php
<?php
Expand Down
Loading