route element file uploads
Add short and long PDF paths to elements, keep pdfPath as a short PDF compatibility alias, and route generic file uploads by fileType.
This commit is contained in:
parent
0d5783ba9c
commit
9bbabc7fa6
28 changed files with 686 additions and 214 deletions
|
|
@ -57,8 +57,7 @@ class ElementController
|
|||
|
||||
public function update(Request $request): JsonResponse
|
||||
{
|
||||
$iconImage = $this->uploadedFileInput($request, 'iconImage');
|
||||
$pdf = $this->uploadedFileInput($request, 'pdf');
|
||||
$file = $this->uploadedFileInput($request, 'file');
|
||||
|
||||
try {
|
||||
$element = $this->updateElement->execute(
|
||||
|
|
@ -71,16 +70,15 @@ class ElementController
|
|||
'iconImageUrl',
|
||||
),
|
||||
richText: $this->stringInput($request, 'richText'),
|
||||
shortPdfPath: $this->stringInput($request, 'shortPdfPath'),
|
||||
longPdfPath: $this->stringInput($request, 'longPdfPath'),
|
||||
pdfPath: $this->stringInput($request, 'pdfPath'),
|
||||
youtubeUrl: $this->stringInput($request, 'youtubeUrl'),
|
||||
iconImageContents: $iconImage['contents'],
|
||||
iconImageOriginalName: $iconImage['originalName'],
|
||||
iconImageMimeType: $iconImage['mimeType'],
|
||||
iconImageSizeBytes: $iconImage['sizeBytes'],
|
||||
pdfContents: $pdf['contents'],
|
||||
pdfOriginalName: $pdf['originalName'],
|
||||
pdfMimeType: $pdf['mimeType'],
|
||||
pdfSizeBytes: $pdf['sizeBytes'],
|
||||
fileType: $this->stringInput($request, 'fileType'),
|
||||
fileContents: $file['contents'],
|
||||
fileOriginalName: $file['originalName'],
|
||||
fileMimeType: $file['mimeType'],
|
||||
fileSizeBytes: $file['sizeBytes'],
|
||||
)
|
||||
);
|
||||
} catch (BadRequestException $exception) {
|
||||
|
|
@ -176,6 +174,8 @@ class ElementController
|
|||
* description: string,
|
||||
* iconImageUrl: string|null,
|
||||
* richText: string,
|
||||
* shortPdfPath: string|null,
|
||||
* longPdfPath: string|null,
|
||||
* pdfPath: string|null,
|
||||
* youtubeUrl: string|null,
|
||||
* }
|
||||
|
|
@ -191,8 +191,16 @@ class ElementController
|
|||
'element-icons/',
|
||||
),
|
||||
'richText' => $element->getRichText(),
|
||||
'shortPdfPath' => $this->storageUrl(
|
||||
$element->getShortPdfPath(),
|
||||
'element-pdfs/',
|
||||
),
|
||||
'longPdfPath' => $this->storageUrl(
|
||||
$element->getLongPdfPath(),
|
||||
'element-pdfs/',
|
||||
),
|
||||
'pdfPath' => $this->storageUrl(
|
||||
$element->getPdfPath(),
|
||||
$element->getShortPdfPath(),
|
||||
'element-pdfs/',
|
||||
),
|
||||
'youtubeUrl' => $element->getYoutubeUrl(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue