edwardspec / mediawiki-aws-s3

Extension:AWS allows MediaWiki to use Amazon S3 (instead of the local directory) to store images.
https://www.mediawiki.org/wiki/Extension:AWS
GNU General Public License v2.0
42 stars 32 forks source link

Could not load image in MultimediaViewer extension #50

Closed tim1mike closed 2 years ago

tim1mike commented 2 years ago

The images open fine in native file preview page and even source file But if I want to open them in MultimediaViewer it says: Could not load image from <here's the image's page link>

My IAM Policy for the user that I use to access S3: { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "s3:*", "Resource": "arn:aws:s3:::my_bucket/*" }, { "Effect": "Allow", "Action": [ "s3:Get*", "s3:List*" ], "Resource": "arn:aws:s3:::my_bucket" } ] }

edwardspec commented 2 years ago

You need a CORS policy, see README.md for an example.

tim1mike commented 2 years ago

First things first, the method explained in Readme file isn't valid as JSON config https://capture.dropbox.com/pixJQiztvFUbP7Q8

Second thing is that I used a template to set CORS policy for the bucket changing only my wiki's URLs instead of example.com https://capture.dropbox.com/nX0YI6UY3GKX5LcV

Still it doesn't work, the only thing is to avoid this extension and it seems like Mediawiki community doesn't offer alternatives for good large Image previews

edwardspec commented 2 years ago

First things first, the method explained in Readme file isn't valid as JSON config

Of course it isn't, it's XML. Refer to the AWS S3 documentation on how to use CORS.

tim1mike commented 2 years ago

As documentation says: If you are configuring CORS in the S3 console, you must use JSON to create a CORS configuration. The new S3 console only supports JSON CORS configurations. https://docs.aws.amazon.com/AmazonS3/latest/userguide/ManageCorsUsing.html?icmpid=docs_s3_hp_cors_editor_page

Whatever it in XML or not, I just followed your information from README.md and created JSON config [ { "AllowedHeaders": [], "AllowedMethods": [ "GET" ], "AllowedOrigins": [ "https://mysite.com" ], "ExposeHeaders": [] } ] I also reinstalled MultimediaViewer and turned it on to check if it works, unfortunately it didn't. It's an error instead of image and there's no logs about that, nothing

tim1mike commented 2 years ago

I tried everything, don't have any clue what's wrong. I got this error in Inspector's Console: Access to image at 'https://mybucket.s3.amazonaws.com/7/78/Rimio.svg' from origin 'https://mysite.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. wth is that? I selected myBucket in S3 > Permissions > Cross-origin resource sharing (CORS) and wrote this: [ { "AllowedHeaders": [ "*" ], "AllowedMethods": [ "GET" ], "AllowedOrigins": [ "*" ], "ExposeHeaders": [] } ] Still it says blocked and the problem is Missing Header

edwardspec commented 2 years ago

Please ask elsewhere. Your issue has nothing to do with this extension.