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