HTTPS clone URL
Subversion checkout URL
Clone this wiki locally
If you want sizes to be available to photos you're fetching from a set, it's not a good idea to call
#get_sizes on each photo, because that will make an HTTP request on each photo, which can be very slow. Instead, when fetching photos from a set, pass in
:include_sizes => true:
photos = Flickrie.photos_from_set(1242379, :include_sizes => true) photo = photos.first photo.medium!(640) photo.source_url # => "http://farm8.staticflickr.com/7049/6946979188_25bb44852b_z.jpg"
When you get an access token, you can use it as long as you want. This is because Flickr uses the OAuth 1.0 protocol, and in that protocol access tokens last forever. And also, they are unique, so, every time you request for an access token from the same user, you will always get the same one. This is really cool, because the user has to authenticate only once, and you just have to store that access key somewhere (in the database, for example, if you're in a web application), and you can always reuse it.
You can also get a photo size in another way.
# These two lines do the same thing photo.medium(500) photo.medium500 # You also have the bang versions photo.medium!(500) photo.medium500! # This is especially useful for the "symbol to proc" that Rails and newer versions of Ruby have photos = Flickrie.photos_from_set(231848, :include_sizes => true) photos.each(&:medium500!) photos.first.size # => "Medium 500"
You can override
timeout like this:
Flickrie.open_timeout = 3 Flickrie.timeout = 4
open_timeoutis the time (in seconds) to wait for the connection with Flickr to open (defaults to 4)
timeoutis the time to wait for one block from Flickr's response to be read (defaults to 6)
If a timeout occurs,
Faraday::Error::TimeoutError is raised.
If you're in a web application, this would go in an initializer.
There is a possibility that, when uploading a photo, an error is raised saying that the apropriate content type cannot be found for that photo. This can happen if the photo you were uploading has some rare extension, which means its content type also isn't well known.
If it happens, you can always pass in the content type manually:
Flickrie.upload("path/to/photo", :title => "Sebastian", :content_type => "CONTENT_TYPE")
If you need to have multiple authenticated users at the same time (for
example, if you're writing a web application), you can do this by
@john = Flickrie::Instance.new(johns_access_token, johns_access_secret) @matthew = Flickrie::Instance.new(matthews_access_token, matthews_access_secret) @john.get_photo_info(74947239) @matthew.upload "/path/to/photo.jpg"
In a web application, let's say you have this form:
<form action="/upload" method="post" enctype="multipart/form-data"> <input type="file" name="file"> <input type="submit"> </form>
And a user selects a file from his disk, and submits the form. When you handle the file upload, you can just pass in the file as the argument (instead of its path):
This currently works only in Rails and Sinatra, but you can also submit pull requests for other frameworks.