From 6f7671238ce4b997c062487aa9b05c5cbd71e1d4 Mon Sep 17 00:00:00 2001 From: Vincent Amstoutz Date: Fri, 6 Dec 2024 15:21:09 +0100 Subject: [PATCH] docs(file-upload): move from core to symfony and update --- admin/file-upload.md | 2 +- core/graphql.md | 9 +++++---- outline.yaml | 2 +- {core => symfony}/file-upload.md | 21 ++++++++++----------- 4 files changed, 17 insertions(+), 17 deletions(-) rename {core => symfony}/file-upload.md (95%) diff --git a/admin/file-upload.md b/admin/file-upload.md index 6cc50907f57..55af6df595b 100644 --- a/admin/file-upload.md +++ b/admin/file-upload.md @@ -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. diff --git a/core/graphql.md b/core/graphql.md index 007b7026653..b815599a0a6 100644 --- a/core/graphql.md +++ b/core/graphql.md @@ -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 @@ -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). diff --git a/outline.yaml b/outline.yaml index 849b020984b..42d4cd8c70f 100644 --- a/outline.yaml +++ b/outline.yaml @@ -14,6 +14,7 @@ chapters: - nelmio-api-doc - user - jwt + - file-upload - title: "API Platform for Laravel" path: laravel items: @@ -65,7 +66,6 @@ chapters: - elasticsearch - controllers - events - - file-upload - jwt - form-data - bootstrap diff --git a/core/file-upload.md b/symfony/file-upload.md similarity index 95% rename from core/file-upload.md rename to symfony/file-upload.md index f3f12ce17f6..dc3b25458b4 100644 --- a/core/file-upload.md +++ b/symfony/file-upload.md @@ -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: @@ -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