Patched documentation problem with VichUploaderBundle#2156
Conversation
…ion for file upload to indicate well the way to use ApiPlatform with VIchUploaderBundle
| new GetCollection(), | ||
| new Post( | ||
| inputFormats: ['multipart' => ['multipart/form-data']], | ||
| controller: CreateMediaObjectAction::class, |
There was a problem hiding this comment.
we do not want to recommend using a controller
There was a problem hiding this comment.
What can we do to create a media with API platform then ? Nobody told me how to do it without using a controller. Is there a way to do this ?
There was a problem hiding this comment.
using a processor like I documented doesn't work?
There was a problem hiding this comment.
I don't see where the documentation for file upload use a processor. Could you provide me an example ?
There was a problem hiding this comment.
I thought I added that documentation but I must have dreamed it haha.
Anyways it's quite straightforward:
final class CreateMediaObjectProcessor implements ProcessorInterface
{
public function process(mixed $data, Operation $operation, array $uriVariables = [], array $context = [])
{
$uploadedFile = $context['request']->files->get('file');
if (!$uploadedFile) {
throw new BadRequestHttpException('"file" is required');
}
$mediaObject = new MediaObject();
$mediaObject->file = $uploadedFile;
return $mediaObject;
}
}
There was a problem hiding this comment.
Noted. I will update the PR when I have time to do this. Thanks for the example.
|
@D3xime Do you plan to keep going? |
This PR is aimed to patch documentation problem in case with VichUploaderBundle
See issue for context : #2058
fix: patch indentation for mutiples markdown Files. Change documentation for file upload to indicate well the way to use ApiPlatform with VIchUploaderBundle