简体   繁体   中英

How to create a TCA field for uploading a PDF file to SQL `mediumblob` in TYPO3 10.4

I am trying to find solution, that will allow user to upload PDF file via TCA. Uploaded file musn't create relation with sys_file_reference .

My current code in TCA:

    'pdf_data' => [
        'exclude' => true,
        'label' => 'PDF file',
        'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
            'pdf_file',
            [
                'appearance' => [
                    'createNewRelationLinkTitle' => 'Add PDF file',
                ],
                'maxitems' => 1,
                'minitems' => 0,
                'overrideChildTca' => [
                    'types' => [
                        '0' => [
                            'showitem' => '
                        --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
                        --palette--;;filePalette'
                        ],
                        \TYPO3\CMS\Core\Resource\File::FILETYPE_TEXT => [
                            'showitem' => '
                        --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
                        --palette--;;filePalette'
                        ],
                        \TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE => [
                            'showitem' => '
                        --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
                        --palette--;;filePalette'
                        ],
                        \TYPO3\CMS\Core\Resource\File::FILETYPE_AUDIO => [
                            'showitem' => '
                        --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
                        --palette--;;filePalette'
                        ],
                        \TYPO3\CMS\Core\Resource\File::FILETYPE_VIDEO => [
                            'showitem' => '
                        --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
                        --palette--;;filePalette'
                        ],
                        \TYPO3\CMS\Core\Resource\File::FILETYPE_APPLICATION => [
                            'showitem' => '
                        --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
                        --palette--;;filePalette'
                        ],
                    ],
                ],
                'filter' => [
                    '0' => [
                        'parameters' => [
                            'allowedFileExtensions' => 'pdf'
                        ]
                    ]
                ],
                'default' => null,
            ],
            'pdf'
        ),
    ]
],

Although Thomas already stated, that it is very uncommon and you really need a good reason to store PDF files in a database, you could still try to provide your own form engine rendering via TCA column type user

https://docs.typo3.org/m/typo3/reference-tca/10.4/en-us/ColumnsConfig/Type/User.html

Just make sure to provide a render type, that will return basic information about the stored data, so that BE users will get a convenient user interface to deal with the files.

Additionally you might want to deal with the data while it gets stored, so providing methods for the DataHandler would be necessary too.

https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/Typo3CoreEngine/Introduction/Index.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM