Comments (2)
We are experiencing the same issue and it's going to be something of a showstopper for us. Given a valid uid, say "avatar/123/big_original.jpg", how can I generate the url for it in javascript? As it stands, Dragonfly base64 encodes it AND Marshals it, so any other language is cut out.
I've been wondering about the reason for this implementation choice but come up short. There's not much extra data in there:
>> Base64.decode64("BAhbBlsHOgZmSSIaaW1hZ2VzLzEvb3JpZ2luYWwuanBnBjoGRVQ.jpg")
=> "\x04\b[\x06[\a:\x06fI\"\x1Aimages/1/original.jpg\x06:\x06ET#"
>> Marshal.load _
=> [[:f, "images/1/original.jpg"]]
Surely it can't be a security measure?
from dragonfly.
It's not a security measure, but it is quicker, easier and more flexible than json encoding it, as well as not relying on any other library.
It easily allows for complex multi-step jobs with option hashes as arguments. It just happens that this the most simple example of a job.
I created routed endpoints for exactly the type of thing you're doing: http://markevans.github.com/dragonfly/file.URLs.html#Routed_Endpoints
If you're using Rails 3, you could create a simple routed endpoint, e.g.:
match '/images/:uid' => Dragonfly[:images].endpoint{|params, app|
app.fetch(params[:uid])
}
Then creating the route in javascript is as simple as
'/images/' + encodeURIComponent(uid)
encodeURIComponent(uid) is needed because forward slashes will confuse the rails routing system.
You could even use sizes, etc.:
match '/images/:uid/:size' => Dragonfly[:images].endpoint{|params, app|
app.fetch(params[:uid]).thumb(params[:size])
}
from dragonfly.
Related Issues (20)
- Can't store resized pdf as jpg HOT 5
- Requesting filename without download file for custom stores HOT 2
- Turning Off Logs HOT 1
- Dragonfly unit test cases failing in Rails 4 HOT 1
- Dragonfly::FileDataStore::UnableToFormUrl: you need to configure server_root for Dragonfly::FileDataStore in order to form urls
- How to ignore "Dragonfly::FileDataStore destroy error"?
- Adding the ability to specify headers for a URL based attachment HOT 3
- Fetching url in the background
- after_assign's copy_to doesn't fire when using retained_image HOT 1
- SSL verification mode option
- warning: loading in progress, circular require considered harmful HOT 1
- is this version of Dragonfly compatible ? HOT 4
- Support for posix-spawn? HOT 2
- Security Issue Report HOT 1
- Guidance on upgrading to 1.4.0 HOT 7
- validate problems?
- CSS style color raising InvalidParameter when using plain generator HOT 1
- Questions about GHSA-qrgf-jqqm-x7xv HOT 2
- Allowing quality and interlace params for imagemagick thumb processor
- Unable to get dragonfly server to work with CORS
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dragonfly.