-
Notifications
You must be signed in to change notification settings - Fork 379
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
several fixes to the AmazonS3Resolver based on feedback #68
Conversation
This allows to extend this resolver and add custom logic around those methods.
This allows to set up certain options e.g. the HTTPS flag.
is the PR ready for review? |
@Spea I wrapped the @neilferreira Do the object url options work for you? You can add a call in your production environment to have the https flag set, while having it unset in your development env. |
@lsmith77 Now it is :-) |
several fixes to the AmazonS3Resolver based on feedback
yeah .. the approach of allowing people to easily extend and add caching is the best way atm. |
Hey, Nearly there! Just a few problems left. The getBrowserPath function is now completely broken, when you're callign getObjectUrl, you're passing the target path rather than the objectPath, so the filter name is not prepended to the URL (so you're linking users to a 404) Am about to test the options array. |
This next problem you might want to fix asap, in 'getObjectUrl' when you call 'get_object_url' you've missed a parameter
You're passing your options inside the preauth variable, other than that, your ssl parameter is working fine. I did ask about a seperate issue related to his back in issue 66 which I'm hoping I can get your help on
As you can see when you use their actual SDK, it returns a URL that no longer appears to have a valid SSL certificate, I don't actually need SSL for the project I'm workign on right now, but I thought i may mention it to you. Have a ponder how you'd like to fix that issue. |
Damn; thanks for the fast reply! PR will be up asap. |
So, the SSL certificates are not valid? - We should notify the AWS support about that. |
And last but not least Can you please add some basic docs on the speed issue, I've just I've just extended the AmazonS3Resolver and added an APC caching layer on top of it and works a treat. Should the remove function become a protected method now too? Since you'd need to override that too to clear your caching layer that sits on top? cheers |
@havvg have you thought about catching the error 'The specified bucket does not exist' inside your store method and reporting it via monolog as an error? At the moment it just fails silently, so a user may not realize that their images are not being served via s3, despite telling it to. That said, there are plenty of errors we should probably try to catch. |
I left the error handling to the user; that's why the resolver is not catching anything (\S3Exception) on its own. |
@havvg I'm not even sure what the deal is with S3 right now. Take a peek here at my examples Non SSL works: SSL breaks (invalid cert) It claims 'The certificate is only valid for the following names: *.s3.amazonaws.com , s3.amazonaws.com' This on the other hand, works: afaik if sometimes 'sg1' (aka singapore) or some location-identifiers are prepended to the URL, so I think doing a straight swap of the URL using regex may cause trouble. Cheers |
@havvg you're definitely missing something If you call getBrowserPath whilst your config is using a bucket that does not exist, there are no errors, If you request that URL that getBrowserPath returns, you see no errors. |
I believe the issue with the certificate is your bucket name. It contains dots, which adds more domain levels. I'm not exactly sure on this, but may be the I'm currently adding unit tests for this resolver. |
ahh you are correct, it is because of the dots. I've always added the dots for the purpose of doing a cname on my domain name to remove the .s3.amazonaws part of the domain name, once I removed the dots it is now returning 'https://s3.amazonaws.com/liip_neilf_net/' - I still think it would be worth stripping of the http: part of the uri, since the method is a 'get browser path' the browser should load the image on the protocol it is currently browsing on. If you disagree I'll just overload that method too, so no biggie. Cheers |
Doesn't the |
The https option does work, as it does return a secure URL. The problem with that is that it will return secure links ALL the time (if the config variable is set), not dependent on the current HTTP request's secure status. I would prefer passing https as false, but embedding the image into the browser with a // prefix, so users browsing via https will use a secure link but users browsing via http will have the non ssl url embedded, as afaik ssl does slow the request down a tad. My biggest use case for this would be facebook apps, when doing a facebook app you MUST have SSL on your domain name, altough less than 50% of users will actually browse your website via SSL, embedding the images hosted on S3 with a https:// prefix (because thats how it has been setup in your service config) for the non-ssl users seem pointless to me. Am I making any sense here? :) |
Yes, now I got your issue here :) For now I would suggest to overwrite the This could be a scenario for the |
Thats fine, I will override it. Another thing to bring to your attention
That snippet is from your constructor within AmazonS3Resolver, on my dev machine that takes between 1.5 and 2.5 seconds to run, this is fairly bad because now ANY page on the entire site, or any CLI script has a bootup time of 1.5 seconds, that function call is unnecessary, as I hinted before you could just catch the errors when you attempt to do a store, and log them from there, that way you're only ever connecting to s3 when needed. With the current setup, the moment services.yml is loaded you're automatically doing a connection to S3, which takes a fair bit of time. If you can push up a fix for this soonish that would be much appreciated. |
Good point, I will remove it from the constructor. |
This is a follow-up on #66.