• Extensions
  • FriendsOfFlarum upload, the intelligent file attachment extension

我想要切割上传的url用来进行鉴权。但当我使用parse_url("{@url}")的时候,url并不能被切割,我该怎么做,或者我该用什么方法进行鉴权


I want to cut the uploaded url for authentication. But when I use parse_url("{@url}"), the url cannot be cut, what should I do or what method should I use to authenticate

    6 days later

    Cagdas you need to use fof formatting and then set the upload template to "just url" I don't know the Turkish name for that 🙈

      Is there ant way to change the upload path to a different folder, outside of the flarum folder?

        jacobgrillo no, but you could symlink the folder to another location, and use webserver rewrite rules to block access to the path if needed.

        I get "Uploading files of this type is not allowed." when I set up S3 adapter and disable local. Does anyone know how it should be configured?

        I am using a Minio instance as S3 endpoint. I have a MIME adapter mapping set to ^image\/.*, S3/Compatible, Default image download template.

          rongcuid "Uploading files of this type is not allowed."

          This usually implies the regex is incorrect. Please share the exact settings by creating and attaching a screenshot 😉

            luceos

            The error has actually changed to "Oops" with 500 error. Now, I don't know how to upload an image here... but here are some settings, pasted verbatim:

            • The regex: ^image\/.*, S3, Default image download template
            • Key/Secret: they are from a Service Account created in Minio. Not going to paste here.
            • Bucket: flarum, a bucket created in Minio
            • Endpoint: http://home.local:9000

            Also, bucket policy:

            {
                "Version": "2012-10-17",
                "Statement": [
                    {
                        "Sid": "AllowPublicRead",
                        "Effect": "Allow",
                        "Principal": {
                            "AWS": [
                                "*"
                            ]
                        },
                        "Action": [
                            "s3:GetObject"
                        ],
                        "Resource": [
                            "arn:aws:s3:::flarum/*"
                        ]
                    }
                ]
            }

            After some testing, I am getting 403 forbidden from my S3 bucket. If someone has done Minio + Flarum Upload, I'd be grateful if they share their experience.

            luceos ok,I think I will make a simple extension to this,thanks for help~

            10 days later

            it worked great!
            but i can't upload animated gif
            how can i fix it?

              jhwandev I think you need to allow image\/gif specifically, but I might be wrong. What have you tried so far?

              7 days later

              Hey I'm having an issue with the "My Media" profile page after doing an import to Flarum and I'm wondering if anyone has any ideas what's wrong.

              This is the page /u/{username}/uploads and the error on page is the "Oops!" error.

              The actual error and first bit of the stack trace:

              Error: Call to a member function preview() on array in /Users/linc/code/flarum/packages/upload/src/Helpers/Util.php:153
              Stack trace:
              #0 /Users/linc/code/flarum/packages/upload/src/Api/Serializers/FileSerializer.php(46): FoF\Upload\Helpers\Util->getBbcodeForFile(Object(FoF\Upload\File))
              #1 /Users/linc/code/flarum/packages/core/src/Api/Serializer/AbstractSerializer.php(88): FoF\Upload\Api\Serializers\FileSerializer->getDefaultAttributes(Object(FoF\Upload\File))
              #2 /Users/linc/code/flarum/vendor/tobscure/json-api/src/Resource.php(169): Flarum\Api\Serializer\AbstractSerializer->getAttributes(Object(FoF\Upload\File), NULL)
              #3 /Users/linc/code/flarum/vendor/tobscure/json-api/src/Resource.php(75): Tobscure\JsonApi\Resource->getAttributes()
              #4 /Users/linc/code/flarum/vendor/tobscure/json-api/src/Collection.php(123): Tobscure\JsonApi\Resource->toArray()
              #5 [internal function]: Tobscure\JsonApi\Collection->Tobscure\JsonApi\{closure}(Object(Tobscure\JsonApi\Resource))
              #6 /Users/linc/code/flarum/vendor/tobscure/json-api/src/Collection.php(124): array_map(Object(Closure), Array)
              #7 /Users/linc/code/flarum/vendor/tobscure/json-api/src/Document.php(181): Tobscure\JsonApi\Collection->toArray()

              I'm not currently populating the upload_method, uuid, or tag columns, but this error is a wrong datatype which makes me wonder if it's something deeper.

              Oh, this is probably the code assuming the tag has to exist here: $template = $this->getTemplate($file->tag);

              I'll see if I can sort out how to set those.

              I'd consider bulletproofing that code a bit.

              can anyone add FTP external storage server to this extension? I even will pay for that.
              I just want uploaded files save to another server via FTP connection.

              a month later

              I am trying to upload microsoft documents. I got the mime types added but when I try to upload a docx file or pptx file I get an error saying those are not supported.

              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|Vnd.openxmlformats-officedocument.wordprocessingml.document|Vnd.openxmlformats-officedocument.presentationml.presentation|Vnd.openxmlformats-officedocument.spreadsheetml.sheet|msword|vnd.ms-powerpoint|vnd.ms-excel))