Giter Club home page Giter Club logo

Comments (6)

rolandstarke avatar rolandstarke commented on July 1, 2024 1

I was not happy with the fix in v1.0.7. I released v1.0.8. You would need to update your config/thumbnail.php and remove the /. That would allow every file on that disk.

  'allowedSources' => [
       // ...
       's3_g' => ['disk' => 's3_gallery', 'path' => ''], // <-- add the new disk
   ],

from laravel-thumbnail.

rolandstarke avatar rolandstarke commented on July 1, 2024

Hey, thanks for the report.

Is the error you are getting like: Source is not allowed. Given path "1.jpg" on disk "test"?

I got the above error when trying it myself with:
\Thumbnail::src('1.jpg', 'test')>url();
It looks like the library needs the leading slash. With the following code it worked:
\Thumbnail::src('/1.jpg', 'test')>url();

I updated the library to support omitting the leading slash. The fix is in v1.0.7.

from laravel-thumbnail.

Askancy avatar Askancy commented on July 1, 2024

Thank you for your reply @rolandstarke

I currently have this and it works:
{{ Thumbnail::preset('gallery')->src('bucket/gallery/'.$value->path, 's3')->url(true) }}

to sort it all out I'm implementing filesystems with scope, and here's the scope I'm using:

        's3_gallery' => [
            'driver' => 'scoped', // This is the new scoped driver!
            'disk' => 's3',       // It uses the `s3` disk above
            'prefix' => 'bucket/gallery',
        ],

So here is the new code, I get the error, however::
{{ Thumbnail::preset('gallery')->src($value->path, 's3_gallery')->url(true) }}

Source is not allowed. Given path "2472/mO84aKBl6lpQnxPNDyPt5gltlge.webp" on disk "s3_gallery"

I tried as you say, with the slash in front, but I keep getting the error:

{{ \Thumbnail::preset('gallery')->src($value->path, 's3_gallery')->url(true) }}

I believe that he has problems using the scoped filesystem

from laravel-thumbnail.

rolandstarke avatar rolandstarke commented on July 1, 2024

I believe the issue could be that in config/thumbnail.php you would need to add the new disk as an allowed source. I hope then it works.

    'allowedSources' => [
        // ...
        's3_g' => ['disk' => 's3_gallery', 'path' => '/'], // <-- add the new disk
    ],

from laravel-thumbnail.

Askancy avatar Askancy commented on July 1, 2024

Thank you very much, the files are now read correctly. Just a small note though:
I added in thumbnail.php:

in allowedSources
's3_g' => ['disk' => 's3_gallery', 'path' => ''],

s3_g What would it stand for? this parameter when used? in my blade i used:

{{ Thumbnail::preset('gallery')->src($value->path, 's3_gallery')->url() }}

It would be really nice if it read data from filesystems.php instead of having to indicate routes. anyway great job, definitely the best thumbnail package

from laravel-thumbnail.

rolandstarke avatar rolandstarke commented on July 1, 2024

s3_g can be any string you want. You don't need and can't use it anywhere. It's used by the library as a param in the URL. ?s=s3_g. I picked a short name, so that the URL does not get longer than needed.

Thanks for the feedback. Allowing every disk from the filesystems.php would simplify the usage of the library. So that you don't need to fiddle around with the allowedSources settings. I am not sure if users rely on the security to list every disk they want to load images from.

from laravel-thumbnail.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.