Coder Social home page Coder Social logo

breaks on long filenames about shrine-url HOT 3 CLOSED

shrinerb avatar shrinerb commented on July 19, 2024
breaks on long filenames

from shrine-url.

Comments (3)

jrochkind avatar jrochkind commented on July 19, 2024

Yeah, so the long filename is just a symptom, really the problem is that when used with shrine-url, the query params are making their way into the id (and thus subsequent storage path), when they shoudln't be.

I worked around in my custom code with a custom generate_location override that includes this (among other things)

        basename = super
          if io.respond_to?(:storage) && io.storage.is_a?(Shrine::Storage::Url)
            basename = URI.parse(basename).path
          end

I am not quite sure what to fix how in shrine itself though, more cleanly.

from shrine-url.

janko avatar janko commented on July 19, 2024

I would try to add a failing test... but I notice now shrine-url doesn't even have any tests, so not sure where to add it.

The tests are here: https://github.com/shrinerb/shrine-url/blob/master/test/url_test.rb 😉

Or wait, maybe it looks like the part of shrine that's extracting the filename suffix (to preserve it as it gets promoted), needs to be smart enough to ignore query parameter at the end, in order to be compatible with shrine-url? That might be it?

Yeah, good catch, that seems to be it:

[1] pry(main)> File.extname("filename.tif?x-amz-algorithm=aws4-hmac-sha256&x-amz-credential=akiajorcl6txivhsdrhq%2f20181119%2fus-east-1%2fs3%2faws4_request&x-amz-date=20181119t182037z&x-amz-expires=14400&x-amz-signedheaders=host&x-amz-signature=fakefake45db944222adfadfadfadf7d20eacce3e6d062979f993db0ffa1e6e")
=> ".tif?x-amz-algorithm=aws4-hmac-sha256&x-amz-credential=akiajorcl6txivhsdrhq%2f20181119%2fus-east-1%2fs3%2faws4_request&x-amz-date=20181119t182037z&x-amz-expires=14400&x-amz-signedheaders=host&x-amz-signature=fakefake45db944222adfadfadfadf7d20eacce3e6d062979f993db0ffa1e6e"

Feel free to send the PR if you can, thanks 😃

from shrine-url.

jrochkind avatar jrochkind commented on July 19, 2024

I wonder if a question mark could hypothetically be a real file suffix. This gets weirdly complicated to do reliably, but I'm going to PR something cause I think it needs fixing.

from shrine-url.

Related Issues (6)

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.