Sha256: ba236956a7fb6578875b32de8e1cc8f9cda3f2852bebb25923c137f4cf44137f
Contents?: true
Size: 1.11 KB
Versions: 53
Compression:
Stored size: 1.11 KB
Contents
class Ey::Core::Client class Real def upload_file(_params={}) params = Cistern::Hash.stringify_keys(_params) mime_type = params["mime_type"] upload_url = params["upload_url"] if string = params["body"] request( :method => :put, :headers => {"Content-Type" => mime_type}, :url => upload_url, :body => string, ) else request( :method => :put, :headers => {"Content-Type" => "multipart/form-data"}, :url => upload_url, :body => Faraday::UploadIO.new(params.fetch("file"), mime_type), ) end end end # Real class Mock def upload_file(_params={}) params = Cistern::Hash.stringify_keys(_params) upload_url = params["upload_url"] temp_file = Tempfile.new("ey-core") temp_file.write(params["body"] || File.read(params.fetch("file"))) temp_file.close self.data[:temp_files][upload_url] = temp_file.path response( :body => "", :status => 200, ) end end # Mock end # Ey::Core::Client
Version data entries
53 entries across 53 versions & 3 rubygems