class MagLoft::TypeloftBlock
Attributes
thumbnail_policy[RW]
Public Instance Methods
queue_upload_thumbnail(file_path, &block)
click to toggle source
# File lib/magloft/typeloft_block.rb, line 18 def queue_upload_thumbnail(file_path, &block) return false if thumbnail_policy.nil? request = Typhoeus::Request.new(thumbnail_policy["url"], method: :put, headers: thumbnail_policy["headers"], body: File.read(file_path), timeout: 200_000) request.on_complete(&block) if block request end
upload_thumbnail(file_path)
click to toggle source
# File lib/magloft/typeloft_block.rb, line 7 def upload_thumbnail(file_path) return false if thumbnail_policy.nil? conn = Faraday.new(url: thumbnail_policy["url"]) do |f| f.ssl.verify = false f.headers = thumbnail_policy["headers"] f.adapter :net_http end response = conn.put(nil, File.read(file_path)) return (response.status == 200) end