FriendsOfFlarum / upload

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

URL incorrect with AWS S3 upload #229

Open daxpandhi opened 4 years ago

daxpandhi commented 4 years ago

Hello,

I've been using AWS S3 for storing the uploads. For the ARN, I had provided the Bucket ARN (incorrectly, I learned, since I am completely new to AWS) which caused issues. The log told me I needed an access point, which I set up and added in the ARN. Now uploads work, but the URL in the post editor after the upload is incorrect.

For example, this is what I get: [upl-image-preview url=https://arn:aws:s3:us-west-1:076786963819:accesspoint/quadflare.s3.us-west-1.amazonaws.com/2020-07-24/1595604947-819461-need-help-quadspinner-gaea-forum-firefox-devel-2020-07-24-1638.png]

While it should be: [upl-image-preview url=https://quadflare.s3.us-west-1.amazonaws.com/2020-07-24/1595604947-819461-need-help-quadspinner-gaea-forum-firefox-devel-2020-07-24-1638.png]

This is the extra prefix the URL contains: arn:aws:s3:us-west-1:076786963819:accesspoint/ (which is the value in my ARN field in the Fof/Upload plugin).

Is this a bug or maybe I have misconfigured something?

My Flarum version is 0.1.0-beta13, and Upload version is 0.9.2 - everything else (including local uploads) is fine.

Thank you, Dax

clarkwinkelmann commented 4 years ago

Hi. Sorry we didn't get back to you earlier.

Unfortunately none of us know much about AWS either, we're just using the Flysystem driver for S3.

I'm not sure what that ARN bit is. If you're using S3 only (without cloudfront and such), you should be able to just fill in the bucket identifier ("Bucket") and datacenter ("Region") and the extension should be able to build a working URL.

matteocontrini commented 4 years ago

I'm not sure what that ARN bit is. If you're using S3 only (without cloudfront and such), you should be able to just fill in the bucket identifier ("Bucket") and datacenter ("Region") and the extension should be able to build a working URL.

The ARN is a unique resource identifier within AWS, but you're correct that it's not required in this case, the bucket name and the region should just work.

daxpandhi commented 3 years ago

Thanks, guys. I'll try that out. In the meantime, I had just edited the php file and hardcoded my URL prefix. :P

japetrus commented 3 years ago

Hi all - I just ran into this issue myself following the exact same path starting with using a bucket arn, looking in the logs, creating access point, etc. The solution, in my case anyways, was as simple as changing the "Bucket" configured in the s3 storage settings from arn:aws:s3:...:accesspoint/name to just the name of the access point as was suggested by others. Everything seems to be working fine now.