fabarea / media_upload

(Mass) upload Media on the Frontend - TYPO3 CMS extension
Other
19 stars 23 forks source link

Compatibility with TYPO3 10.4 LTS #49

Closed freeATweb closed 3 years ago

freeATweb commented 3 years ago

Hello,

I'm currently working on the compatibility of this extension for TYPO3 10.4 LTS.

public function __construct($storage = NULL) { $this->storage = $storage; $this->gifCreator = GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\Imaging\GifBuilder::class); $this->gifCreator->absPrefix = \TYPO3\CMS\Core\Core\Environment::getPublicPath(); }

But there is still a problem with the file upload itself. There is no folder and file created in typo3temp/MediaUpload. No JAvascript or AJAX-Errors - the preview of the uploaded image shows up (see attachment)

But no file & folder is created (like typo3temp/MediaUpload/5ac514a5-7a95-40ef-a97c-ceecf8929415/dummy-image.jpg)

FineUploaderBasic request option "paramsInBody" is set to false (Ticket #42 )

Can someone help me?

Best regards media-upload-screen1

freeATweb commented 3 years ago

Hello,

fixed it: Changed: /Classes/FileUpload/UploadedFileAbstract.php:

/**
     * Get the file with its absolute path.
     *
     * @return string
     */
    public function getFileWithAbsolutePath()
    {
        return $this->uploadFolder . '/' . $this->name;
    }

NOTICE: In the controllers of your own extensions, the usage of

$file = $storage->addFile(
            $uploadedFile->getTemporaryFileNameAndPath(),
            $customerStorage,
            $uploadedFile->getFileName(),
            'changeName'
   );

is deprecated. Use: $file = $storage->addFile( $uploadedFile->getTemporaryFileNameAndPath(), $customerStorage, $uploadedFile->getFileName(), 'rename' ); instead.

Example:

$contentFiles = $this->uploadFileService->getUploadedFiles('contentfiles');

        // Process uploaded files and move them into a Resource Storage (FAL)
        foreach($contentFiles as $uploadedFile) {
            /** @var \Fab\MediaUpload\UploadedFile $uploadedFile */
            $uploadedFile->getTemporaryFileNameAndPath();

            /** @var File $file */
            $file = $storage->addFile(
            $uploadedFile->getTemporaryFileNameAndPath(),
            $customerStorage,
            $uploadedFile->getFileName(),
            'rename'
            );
            // Create File Reference
        //    $newFileReference = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\EXTENSION\\Domain\\Model\\FileReference');
        //    $newFileReference->setOriginalResource($file);
            $newFileReference = $this->objectManager->get('TYPO3\EXTENSION\Domain\Model\FileReference');
            $newFileReference->setFile($file);
            $newPlaces->addContentfiles($newFileReference);
        }