Skip to content

Instantly share code, notes, and snippets.

@trevmex
Created March 2, 2010 21:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trevmex/319951 to your computer and use it in GitHub Desktop.
Save trevmex/319951 to your computer and use it in GitHub Desktop.
module ActiveResource
class Base
# Returns the raw data to display the thumbnail of an Alfresco document
def thumbnail
if self.doclib
begin
Net::HTTP.start(self.class.site.host, self.class.site.port) do |http|
req = Net::HTTP::Get.new(self.doclib, {'Content-Type' => 'image/png'})
req.basic_auth self.class.user, self.class.password
http.request(req).body
end
rescue Exception => error_message
STDERR.puts "Failed to connect to #{self.class.site.to_s}: #{error_message}"
raise
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment