feat: ajout de la fonctionnalité de conversion de fichiers de bande dessinée, permettant la conversion de fichiers CBR en CBZ. Intégration d'un service de conversion, d'une API pour gérer les téléchargements, et mise en place de validations pour les fichiers uploadés. Tests unitaires ajoutés pour garantir le bon fonctionnement de cette nouvelle fonctionnalité.
This commit is contained in:
parent
b4bfa48d00
commit
7a05934116
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Conversion\Infrastructure\ApiPlatform\Resource;
|
||||
|
||||
use ApiPlatform\Metadata\ApiResource;
|
||||
use ApiPlatform\Metadata\Post;
|
||||
use ApiPlatform\OpenApi\Model;
|
||||
use App\Domain\Conversion\Infrastructure\ApiPlatform\Controller\ConvertFileController;
|
||||
use Symfony\Component\HttpFoundation\File\File;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
#[ApiResource(
|
||||
shortName: 'Conversion',
|
||||
operations: [
|
||||
new Post(
|
||||
uriTemplate: '/conversions/convert',
|
||||
controller: ConvertFileController::class,
|
||||
deserialize: false,
|
||||
openapiContext: [
|
||||
'summary' => 'Convert comic book file to CBZ',
|
||||
'description' => 'Converts a CBR or CBZ file to CBZ format and returns the converted file for download',
|
||||
'requestBody' => [
|
||||
'content' => [
|
||||
'multipart/form-data' => [
|
||||
'schema' => [
|
||||
'type' => 'object',
|
||||
'required' => ['file'],
|
||||
'properties' => [
|
||||
'file' => [
|
||||
'type' => 'string',
|
||||
'format' => 'binary',
|
||||
'description' => 'Comic book file to convert (CBR, CBZ, max 150MB)'
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
],
|
||||
'responses' => [
|
||||
'200' => [
|
||||
'description' => 'File converted successfully',
|
||||
'content' => [
|
||||
'application/x-cbz' => [
|
||||
'schema' => [
|
||||
'type' => 'string',
|
||||
'format' => 'binary'
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
)
|
||||
]
|
||||
)]
|
||||
class ConvertFileResource
|
||||
{
|
||||
public ?File $file = null;
|
||||
|
||||
public ?string $fileName = null;
|
||||
|
||||
// Propriétés pour la réponse
|
||||
public mixed $fileContent = null;
|
||||
public ?string $filename = null;
|
||||
public ?string $originalConvertedFilePath = null;
|
||||
}
|
||||
Reference in New Issue
Block a user