Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Duplicate Bucket Name in Endpoint #16

Closed
mattcdavis1 opened this issue Aug 4, 2020 · 10 comments
Closed

[Bug] Duplicate Bucket Name in Endpoint #16

mattcdavis1 opened this issue Aug 4, 2020 · 10 comments

Comments

@mattcdavis1
Copy link

mattcdavis1 commented Aug 4, 2020

When using the default endpoint value provided by Digital Ocean (i.e. 'https://ecabling.nyc3.digitaloceanspaces.com') the S3 plugin duplicates the bucket name in the URL and operations fail (i.e. 'https://ecabling.ecabling.nyc3.digitaloceanspaces.com'). Using an alternate URL (i.e. https://nyc3.digitaloceanspaces.com/ecabling') resolves the upload issue but causes issues elsewhere (url generation).

As far as I can tell, 1 line1 of code fixes this (i just implemented this so not sure if any other side effects). In Volume.php I added the below lines to the createAdapter method:

$config['bucket_endpoint'] = true;
protected function createAdapter()
{
    $config = $this->_getConfigArray();

    $config['bucket_endpoint'] = true;

    $client = static::client($config);

    return new AwsS3Adapter($client, $this->getBucket(), $this->getSubfolder());
}
@setheryb
Copy link

setheryb commented Aug 9, 2020

@mattcdavis1 I'm running into the same issue. I'll admit that I don't know a ton about plugin dev and whatnot...but are you dropping all of that at the end of Volume.php? Or is the first line somewhere else in another file? Just wanting to understand. Thanks

@mattcdavis1
Copy link
Author

Hey @setheryb - most of those lines are already present in the file. You just need to add the following line on line #176 of Volume.php:

$config['bucket_endpoint'] = true;

@setheryb
Copy link

setheryb commented Aug 9, 2020

@mattcdavis1 Gotcha. Thanks. I see that clearly now that you pointed it. Appreciate it.

@aelvan
Copy link
Contributor

aelvan commented Aug 9, 2020

Hi,

The endpoint is suppose to be without the bucket name, ie https://nyc3.digitaloceanspaces.com, I've clarified this in the docs. I'd strongly advice against the $config['bucket_endpoint'] = true; approach, it's just incidental that it works. And the URL is configured independently of the API endpoint, they don't have to be related at all.

@aelvan aelvan closed this as completed Aug 9, 2020
@mattcdavis1
Copy link
Author

@aelvan - the non-bucket naming approach breaks as well.

@aelvan aelvan reopened this Aug 9, 2020
@aelvan
Copy link
Contributor

aelvan commented Aug 9, 2020

Oh really? I just tested, and it worked. What's the error you're seeing? Do uploads fail?

@mattcdavis1
Copy link
Author

No - with the non-bucket approach my recollection is that the links were failing in the asset listing view. I'll verify and post back.

@aelvan
Copy link
Contributor

aelvan commented Aug 9, 2020

Hmm, ok, can you test again, and make sure that the enpoint is without the bucketname (https://nyc3.digitaloceanspaces.com/) and the Volume URL is with ('https://ecabling.nyc3.digitaloceanspaces.com) (and without the bucket_endpoint hack of course).

@mattcdavis1
Copy link
Author

@aelvan - that does work - thanks! I think what threw me off was that I thought both base urls needed to be consistent (either both with or both without ecabling in the subdomain). It'd probably be helpful to update the naming of field settings to be more inline with DO to help with this (i think there's a pull request for this). Thanks again!

@aelvan
Copy link
Contributor

aelvan commented Aug 9, 2020

Glad you got it sorted out!

I can see how those two settings can be a bit confusing, since the values would normally be very similar. But they could also be completely different (if for instance you put a pull CDN in front of the Spaces bucket). The URL is a Craft setting that every volume has, whereas the other ones are custom. I think the docs just need to be a bit clearer with example values, I'll have a look at it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants