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

Cache paths 404 response since upgrade to AWS SDK 3 #726

Closed
PaddyLock opened this issue Apr 13, 2016 · 9 comments
Closed

Cache paths 404 response since upgrade to AWS SDK 3 #726

PaddyLock opened this issue Apr 13, 2016 · 9 comments

Comments

@PaddyLock
Copy link

The paths to my images are returning 404 responses since upgrading to AWS SDK 3

Packages installed

"aws/aws-sdk-php-symfony": "~1.0",
"aws/aws-sdk-php": "3.2.6",
"liip/imagine-bundle": "dev-master",

And in my config

services:
    helios.imagine.cache.resolver.amazon_s3:
        class: Liip\ImagineBundle\Imagine\Cache\Resolver\AwsS3Resolver
        arguments:
            - "@aws.s3"
            - "%s3_bucket%"
        tags:
            - { name: 'liip_imagine.cache.resolver', resolver: 'profile_aws' }

aws:
    version: latest
    region: us-east-1
    credentials:
        key: '%aws_key%'
        secret: '%aws_secret%'
    S3:
        version: '2006-03-01'

knp_gaufrette:
    adapters:
        amazon:
            aws_s3:
                service_id: aws.s3
                bucket_name: %s3_bucket%
                options:
                    create: true
    filesystems:
        amazonS3:
            adapter: amazon

    stream_wrapper: ~

liip_imagine:
    cache: 'profile_aws'
    filter_sets:
        product_list:
            data_loader: stream.amazon
            quality: 80
            filters:
                thumbnail: { size: [100, 100], mode: inset }

This is an example of a path generated for an image which returns a 404 response

/media/cache/resolve/product_list/uploads/images/products/ee1d4c25caff7b7c0b14f017af92b6d63d861.jpg

@PaddyLock PaddyLock changed the title Cache paths broken since upgrade to AWS SDK 3 Cache paths 404 response since upgrade to AWS SDK 3 Apr 13, 2016
@Nightbr
Copy link

Nightbr commented Sep 30, 2016

hey, same error here
Also my folder media is symlink (maybe the problem), it works fine without the symlink...

@jehaby
Copy link
Contributor

jehaby commented Sep 30, 2016

Is there anything useful in your log files? ( {{your_project_root}}/var/log/ }} by default in symfony )

@Nightbr
Copy link

Nightbr commented Sep 30, 2016

Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "Source image could not be found" at /var/www/welp/shared/vendor/liip/imagine-bundle/Controller/ImagineController.php line 101

I resolved the problem:

  1. fix the version "liip/imagine-bundle": "1.6.*",
  2. remove the symlink /var/www/welp/current/web/media -> /var/www/welp/shared/media
  3. recreate and chmod /var/www/welp/current/web/media

NOTE: I am using capistrano to deploy my app (capistrano automaticaly create symlink to shared dir).

Also in the log:

"previous":{"class":"Liip\ImagineBundle\Exception\Binary\Loader\NotLoadableException","message":" Source image invalid "/var/www/welp/shared/web/uploads/tmp/43b04f0afab14e6c440418bda56c28917a2552b1.png" as it is outside of the defined root path","code":0,"file":"/var/www/welp/shared/vendor/liip/imagine-bundle/Binary/Loader/FileSystemLoader.php:67","trace":["/var/www/welp/shared/vendor/liip/imagine-bundle/Imagine/Data/DataManager.php:125","/var/www/welp/shared/vendor/liip/imagine-bundle/Controller/ImagineController.php:95","{"function":"filterAction","class":"Liip\ImagineBundle\Controller\ImagineController","type":"->","args":["[object] (Symfony\Component\HttpFoundation\Request: GET /media/cache/resolve/user_small/uploads/tmp/43b04f0afab14e6c440418bda56c28917a2552b1.png

So that was it, the Loader followed the symlink and throw an error because the media was outside the defined root.

NOTE2: it was working well in older version of liip

@robfrawley
Copy link
Collaborator

robfrawley commented Oct 1, 2016

@Nightbr You don't have to remove the symbolic link, you simply need to set an appropriate data_root value. For example:

liip_imagine:
  loaders:
    default:
      filesystem:
        data_root: "/var/www/welp"

This will resolve the NotFoundHttpException exception being thrown. This check was less strict in older versions, allowing for paths to be outside the data root (which in your case would default to /var/www/welp/current/). Since your images are actually outside this path, you need to set the value of data_root so that they are not outside this path.

@sloba88
Copy link

sloba88 commented Dec 28, 2016

I've stumbled on the same problem. The thing is that I don't have every image under same directory, some were symlinked between different releases and some are specific to the release (static), so I really can't find solution to my problem with this config.

@robfrawley
Copy link
Collaborator

@sloba88 You can always use bind mounts in place of symbolic links to mount all locations within a single root path.

@robfrawley
Copy link
Collaborator

@sloba88 Any luck?

@sloba88
Copy link

sloba88 commented Dec 31, 2016

@robfrawley I solved it by moving my static images in sub directory of dynamic. As I've using Capistrano to deploy an I have multiple releases I am not sure how well bind mount would work for me.

@michellesanver
Copy link
Contributor

I think there's a reasonable workaround now, possibly we can document this better? If you can think of anything we can do to improve this, or to document it better, either open a PR or a new issue. And thanks a lot :)

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

6 participants