FriendsOfFlarum upload, the intelligent file attachment extension
Hi, sorry if this has already been asked, but is there a way to store uploads in a non-public directory. The assets directory is publicly accessible so once someone has the link to an upload, there's no longer a way to ensure someone has authenticated before viewing the file.
Great extension though!
I am Trying to upload images with Fof/upload plugin, but view them as thumbnails. Also, i have a ./. rule to be able to upload every type of file, since is just an internal forum security is not a problem here. Is there a way of doing that? Regards
naturistwiki By default fof/upload
doesn't provide this functionality, but in theory it should absolutely be possible! If I understand you correctly, you can subscribe to the WillBeDownloaded
event and then put your custom logic there how to constrain downloads depending on your requirements.
Lolren I don't think there is a way to straight up allow uploading files of any type. Even if it's just an internal forum, I would strongly recommend against that anyway.
If you want to allow the most common file types, you can use the following mimetype regex (see GitHub Readme):
(video\/(3gpp|mp4|mpeg|quicktime|webm))|(audio\/(aiff|midi|mpeg|mp4))|(image\/(gif|jpeg|png))|(application\/(x-(7z|rar|zip)-compressed|zip|arj|x-(bzip2|gzip|lha|stuffit|tar)|pdf))
Does this help you?
A regex of .*
will allow any file to be uploaded and shown based on the selected template for that.
Any reason why the text files preview box only shows the first 5 lines?
I guess it's caused by this code: FriendsOfFlarum/uploadblob/master/src/Formatter/TextPreview/FormatTextPreview.php#L52
I'd like to preview the whole file.
Example:
- Edited
@IanM - First off, thank you so much for this extension.
I am getting a "Uploading this file type is not allowed." error when I try to upload a .zip file.
I ensured I added a new mime type and added the recommended line
(video\/(3gpp|mp4|mpeg|quicktime|webm))|(audio\/(aiff|midi|mpeg|mp4))|(image\/(gif|jpeg|png))|(application\/(x-(7z|rar|zip)-compressed|zip|arj|x-(bzip2|gzip|lha|stuffit|tar)|pdf))
It's set on Local, and Default File Download Template. What else should I be doing?
Edit: I discovered that when I clicked the + button to add another mime type, it did not save the line posted above when I refreshed the page. I ended up having to add another one as well and left it blank. So now I have the image one that was there by default, the regex posted above that allows all, and a new blank one. That seemed to let me save it.
Hello, after a long time I returned to playing with this extension. I updated it to the latest version and when I try to upload any file I get this error. Can someone take a look at this?
I would also like to ask when the error of cleaning old abandoned files placed via S3 will be fixed?
Or should we not expect any changes before the release of flarum 2.0?
[2024-07-26 16:10:44] flarum.ERROR: BadMethodCallException: Call to undefined method FoF\Upload\File::byUuid() in /var/www/panel/vendor/illuminate/support/Traits/ForwardsCalls.php:71
Stack trace:
#0 /var/www/panel/vendor/illuminate/support/Traits/ForwardsCalls.php(36): Illuminate\Database\Eloquent\Model::throwBadMethodCallException()
#1 /var/www/panel/vendor/illuminate/database/Eloquent/Model.php(2132): Illuminate\Database\Eloquent\Model->forwardCallTo()
#2 /var/www/panel/vendor/flarum/core/src/Database/AbstractModel.php(224): Illuminate\Database\Eloquent\Model->__call()
#3 /var/www/panel/vendor/illuminate/database/Eloquent/Model.php(2144): Flarum\Database\AbstractModel->__call()
#4 /var/www/panel/vendor/fof/upload/src/Repositories/FileRepository.php(69): Illuminate\Database\Eloquent\Model::__callStatic()
#5 /var/www/panel/vendor/fof/upload/src/Repositories/FileRepository.php(83): FoF\Upload\Repositories\FileRepository->findByUuid()
#6 /var/www/panel/vendor/fof/upload/src/Commands/UploadHandler.php(92): FoF\Upload\Repositories\FileRepository->createFileFromUpload()
#7 [internal function]: FoF\Upload\Commands\UploadHandler->FoF\Upload\Commands\{closure}()
#8 /var/www/panel/vendor/illuminate/collections/Collection.php(695): array_map()
#9 /var/www/panel/vendor/fof/upload/src/Commands/UploadHandler.php(64): Illuminate\Support\Collection->map()
#10 /var/www/panel/vendor/illuminate/bus/Dispatcher.php(122): FoF\Upload\Commands\UploadHandler->handle()
#11 /var/www/panel/vendor/illuminate/pipeline/Pipeline.php(128): Illuminate\Bus\Dispatcher->Illuminate\Bus\{closure}()
#12 /var/www/panel/vendor/illuminate/pipeline/Pipeline.php(103): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#13 /var/www/panel/vendor/illuminate/bus/Dispatcher.php(132): Illuminate\Pipeline\Pipeline->then()
#14 /var/www/panel/vendor/illuminate/bus/Dispatcher.php(78): Illuminate\Bus\Dispatcher->dispatchNow()
#15 /var/www/panel/vendor/fof/upload/src/Api/Controllers/UploadController.php(60): Illuminate\Bus\Dispatcher->dispatch()
#16 /var/www/panel/vendor/flarum/core/src/Api/Controller/AbstractSerializeController.php(116): FoF\Upload\Api\Controllers\UploadController->data()
#17 /var/www/panel/vendor/flarum/core/src/Http/RouteHandlerFactory.php(41): Flarum\Api\Controller\AbstractSerializeController->handle()
#18 /var/www/panel/vendor/flarum/core/src/Http/Middleware/ExecuteRoute.php(27): Flarum\Http\RouteHandlerFactory->Flarum\Http\{closure}()
#19 /var/www/panel/vendor/laminas/laminas-stratigility/src/Next.php(52): Flarum\Http\Middleware\ExecuteRoute->process()
#20 /var/www/panel/vendor/fof/reactions/src/Middleware/BindRequestToContainer.php(35): Laminas\Stratigility\Next->handle()
#21 /var/www/panel/vendor/laminas/laminas-stratigility/src/Next.php(52): FoF\Reactions\Middleware\BindRequestToContainer->process()
#22 /var/www/panel/vendor/flarum/core/src/Api/Middleware/ThrottleApi.php(33): Laminas\Stratigility\Next->handle()
#23 /var/www/panel/vendor/laminas/laminas-stratigility/src/Next.php(52): Flarum\Api\Middleware\ThrottleApi->process()
#24 /var/www/panel/vendor/flarum/core/src/Http/Middleware/CheckCsrfToken.php(44): Laminas\Stratigility\Next->handle()
#25 /var/www/panel/vendor/laminas/laminas-stratigility/src/Next.php(52): Flarum\Http\Middleware\CheckCsrfToken->process()
#26 /var/www/panel/vendor/flarum/core/src/Http/Middleware/ResolveRoute.php(69): Laminas\Stratigility\Next->handle()
#27 /var/www/panel/vendor/laminas/laminas-stratigility/src/Next.php(52): Flarum\Http\Middleware\ResolveRoute->process()
#28 /var/www/panel/vendor/flarum/core/src/Http/Middleware/SetLocale.php(51): Laminas\Stratigility\Next->handle()
#29 /var/www/panel/vendor/laminas/laminas-stratigility/src/Next.php(52): Flarum\Http\Middleware\SetLocale->process()
#30 /var/www/panel/vendor/flarum/core/src/Http/Middleware/AuthenticateWithHeader.php(58): Laminas\Stratigility\Next->handle()
#31 /var/www/panel/vendor/laminas/laminas-stratigility/src/Next.php(52): Flarum\Http\Middleware\AuthenticateWithHeader->process()
#32 /var/www/panel/vendor/flarum/core/src/Http/Middleware/AuthenticateWithSession.php(31): Laminas\Stratigility\Next->handle()
#33 /var/www/panel/vendor/laminas/laminas-stratigility/src/Next.php(52): Flarum\Http\Middleware\AuthenticateWithSession->process()
#34 /var/www/panel/vendor/flarum/core/src/Http/Middleware/RememberFromCookie.php(52): Laminas\Stratigility\Next->handle()
#35 /var/www/panel/vendor/laminas/laminas-stratigility/src/Next.php(52): Flarum\Http\Middleware\RememberFromCookie->process()
#36 /var/www/panel/vendor/flarum/core/src/Http/Middleware/StartSession.php(61): Laminas\Stratigility\Next->handle()
#37 /var/www/panel/vendor/laminas/laminas-stratigility/src/Next.php(52): Flarum\Http\Middleware\StartSession->process()
#38 /var/www/panel/vendor/flarum/core/src/Api/Middleware/FakeHttpMethods.php(29): Laminas\Stratigility\Next->handle()
#39 /var/www/panel/vendor/laminas/laminas-stratigility/src/Next.php(52): Flarum\Api\Middleware\FakeHttpMethods->process()
#40 /var/www/panel/vendor/flarum/core/src/Http/Middleware/ParseJsonBody.php(28): Laminas\Stratigility\Next->handle()
#41 /var/www/panel/vendor/laminas/laminas-stratigility/src/Next.php(52): Flarum\Http\Middleware\ParseJsonBody->process()
#42 /var/www/panel/vendor/flarum/core/src/Http/Middleware/HandleErrors.php(57): Laminas\Stratigility\Next->handle()
#43 /var/www/panel/vendor/laminas/laminas-stratigility/src/Next.php(52): Flarum\Http\Middleware\HandleErrors->process()
#44 /var/www/panel/vendor/flarum/core/src/Http/Middleware/InjectActorReference.php(25): Laminas\Stratigility\Next->handle()
#45 /var/www/panel/vendor/laminas/laminas-stratigility/src/Next.php(52): Flarum\Http\Middleware\InjectActorReference->process()
#46 /var/www/panel/vendor/laminas/laminas-stratigility/src/MiddlewarePipe.php(77): Laminas\Stratigility\Next->handle()
#47 /var/www/panel/vendor/middlewares/request-handler/src/RequestHandler.php(84): Laminas\Stratigility\MiddlewarePipe->process()
#48 /var/www/panel/vendor/laminas/laminas-stratigility/src/Next.php(52): Middlewares\RequestHandler->process()
#49 /var/www/panel/vendor/middlewares/base-path-router/src/BasePathRouter.php(99): Laminas\Stratigility\Next->handle()
#50 /var/www/panel/vendor/laminas/laminas-stratigility/src/Next.php(52): Middlewares\BasePathRouter->process()
#51 /var/www/panel/vendor/laminas/laminas-stratigility/src/Middleware/OriginalMessages.php(36): Laminas\Stratigility\Next->handle()
#52 /var/www/panel/vendor/laminas/laminas-stratigility/src/Next.php(52): Laminas\Stratigility\Middleware\OriginalMessages->process()
#53 /var/www/panel/vendor/middlewares/base-path/src/BasePath.php(73): Laminas\Stratigility\Next->handle()
#54 /var/www/panel/vendor/laminas/laminas-stratigility/src/Next.php(52): Middlewares\BasePath->process()
#55 /var/www/panel/vendor/flarum/core/src/Http/Middleware/ProcessIp.php(24): Laminas\Stratigility\Next->handle()
#56 /var/www/panel/vendor/laminas/laminas-stratigility/src/Next.php(52): Flarum\Http\Middleware\ProcessIp->process()
#57 /var/www/panel/vendor/laminas/laminas-stratigility/src/MiddlewarePipe.php(77): Laminas\Stratigility\Next->handle()
#58 /var/www/panel/vendor/laminas/laminas-stratigility/src/MiddlewarePipe.php(66): Laminas\Stratigility\MiddlewarePipe->process()
#59 /var/www/panel/vendor/laminas/laminas-httphandlerrunner/src/RequestHandlerRunner.php(73): Laminas\Stratigility\MiddlewarePipe->handle()
#60 /var/www/panel/vendor/flarum/core/src/Http/Server.php(45): Laminas\HttpHandlerRunner\RequestHandlerRunner->run()
#61 /var/www/panel/public/index.php(26): Flarum\Http\Server->listen()
#62 {main}
Is this a new problem or I’m finding it now? I am an admin and tried to delete the media entry of a user and I get permission error.
luceos I found out the cause of the permission errors when deleting user uploads, it's the Sudo Mode Extension. The current workaround is to first open the administration page that will ask me to enter into "sudo mode" for some time and it's only then that I can delete user uploads. @clarkwinkelmann is there anything that needs to be changed either on the upload extension or the sudo extension in order to fix this bug?
CyberGene it's been a while since I used FoF Upload. Are we talking about soft deletion (hide) or permanent deletion? Because the logic for both is different in FoF Upload.
I took a look at the source code for both extensions, don't see any obvious issue. Sudo Mode has a whitelist of abilities it's supposed to modify, the other abilities including those added by extensions should not be impacted.
I'll need to reproduce in a test environment to get a better idea. Not sure when I will have time for that.
- Edited
clarkwinkelmann Are we talking about soft deletion (hide) or permanent deletion? Because the logic for both is different in FoF Upload.
I think it's the soft deletion: I, as an admin, open some other user's profile, then click on "User Uploads" and try to delete some of the entries. I believe it's just soft deletion since deleting the actual file (which in my case is on AWS S3, but I guess it doesn't matter) has never been implemented, @luceos might have to confirm.
how to make popup image ?
aliyeW that's not a feature of this extension