FriendsOfFlarum / upload

The file upload extension with insane intelligence for your Flarum forum.
https://discuss.flarum.org/d/4154
MIT License
175 stars 94 forks source link

Cannot resolve host correctly for AWS S3 module #307

Open shawPLUSroot opened 2 years ago

shawPLUSroot commented 2 years ago

Bug Report

Current Behavior I built the Minio in a server which is compatible with AWS S3 API and initially it works fine, but when I tried to add the SSL certificate to my domain and attached it to my IP address which holds the Minio server, it crashed. The main problem I checked in my logs is the extension resolved the host incorrectly. It's a weird action -- the normal host should be host:port/bucket_name/image.jpg, but it gave:

bucket_name.host:port/bucket_name/image.jpg. Also, the host should be starting with https, however, it gave http instead. Can you help me solve this issue?

Expected Behavior It should upload image normally.

Screenshots

截屏2022-01-23 15 28 41

Environment

Possible solution(s)

I think it might be due to the original code for dealing with S3 API. But I don't know which file is relevant.

clarkwinkelmann commented 2 years ago

It seems like we are passing the options quasi-verbatim to the AWS SDK so I'm not sure what else we could do:

https://github.com/FriendsOfFlarum/upload/blob/fe72df5d93753c011d099242fcc43b38a5b66dda/src/Adapters/Manager.php#L110-L122

Have you tried to change the awsS3UsePathStyleEndpoint setting? (not sure how it's called in the frontend)

I don't see where the HTTPS/HTTP issue is from your screenshot.

Can you share a screenshot/copy of your S3 settings in the Flarum admin panel so we can compare with the error message?

shawPLUSroot commented 2 years ago
截屏2022-01-24 12 28 20 截屏2022-01-24 12 29 26

It seems that I solve the https problem as long as I add https:// for the endpoint part. But still, it would put the bucket_name (in my case, the name is "images") in front of my domain -- which leads to the unresolved host https://images.my_domain:9000/date/image_name. 😅 This is really weird.....

shawPLUSroot commented 2 years ago

Can someone plz help me?

clarkwinkelmann commented 2 years ago

Unfortunately I don't have any other idea... A change might be required in the extension to make this format work.