1up-lab/OneupUploaderBundle

AbstractController->dispatchPostEvents expects Symfony File instead of FlysystemFile

seizan8 opened this issue · 6 comments

Bug Report

Uploading a file returns Error:

"Oneup\UploaderBundle\Controller\AbstractController::dispatchPostEvents(): Argument #1 ($uploaded) must be of type Symfony\Component\HttpFoundation\File\File, Oneup\UploaderBundle\Uploader\File\FlysystemFile given, called in /var/www/html/vendor/oneup/uploader-bundle/src/Controller/AbstractController.php on line 128"

Q A
Symfony 6.4.3
Oneup/UploaderBundle 5.0.0
Oneup/FlysystemBundle 4.11.2
Dropzone 6.0.0-beta.2

Summary

After setting up Oneup/UploaderBundle, Oneup/FlysystemBundle and Dropzone I tested out the upload and received an error.

It seems like Oneup\UploaderBundle\Uploader\Storage\FlysystemStorage->upload returns a Oneup\UploaderBundle\Uploader\File\FlysystemFile. And Oneup\UploaderBundle\Controller->dispatchPostEvents expects a Symfony\Component\HttpFoundation\File\File.

Either FlysystemFile needs to extend the Symfony File class. Or the parameter type in AbstractController->dispatchPostEvents should be changed to Oneup\UploaderBundle\Uploader\File\FileInterface.

How to reproduce

I believe it happens whenever you use Oneup/UploaderBundle v5.0.0 und try to upload a file.

Just hit the same bug, but with Uppy library.
Problem arised after: updating to Oneup/UploaderBundle 5.0.0.

Q A
Symfony 6.4.3
Oneup/UploaderBundle 5.0.0
Oneup/FlysystemBundle 4.12.0
Uppy 3.23

@seizan8 / @Rikijs thanks for reporting! 🙏

Does #445 (dev-fix/wrong-typehint) solve your issue?

Hello, @bytehead!
Yes, for me, patch allowes upload to function as intended.
Thank you for a speedy fix!

5.0.1 is out! Thanks again for reporting! 🙏

@bytehead Sorry for the late reply. Can confim, it works now with v5.0.1.
Thank you for the quick fix! :)

You're welcome! Thanks for the feedback.