URI.parse(‘https://graph.facebook.com/me/photos?access_token=#{params[:access_token]}’)
File.open(params[@tempfile]) do |jpg|
req = Net::HTTP::Post::Multipart.new url.path,
“file” => UploadIO.new(jpg, “image/jpeg”, “image.jpg”)
res = Net::HTTP.start(url.host, url.port) do |http|
http.request(req)
end
end
But:
It is not sending the data.
I cannot find how to send the params[:message] with the file in
order to have a caption for the image.
n = Net::HTTP.new(url.host, url.port)
n.use_ssl = true
n.verify_mode = OpenSSL::SSL::VERIFY_NONE
n.start do |http|
http.request(req)
end
end
private
def mime_for_file(f)
m = MIME::Types.type_for(f.path.split('').last)
m.empty? ? "application/octet-stream" : m.to_s
end
end
n = Net::HTTP.new(url.host, url.port)
n.use_ssl = true
n.verify_mode = OpenSSL::SSL::VERIFY_NONE
n.start do |http|
http.request(req)
end
end
private
def mime_for_file(f)
m = MIME::Types.type_for(f.path.split('').last)
m.empty? ? "application/octet-stream" : m.to_s
end
end