I\'m trying to upload an image to PingFM. Their documentation says:
media – base64 encoded media data.
I can access this image via the URL.
To encode a file:
require 'base64'
Base64.encode64(File.open("file_path", "rb").read)
To produce the file from the encoded string:
require 'base64'
encoded_string = Base64.encode64(File.open("file_path", "rb").read)
File.open(file_name_to_create, "wb") do |file|
file.write(Base64.decode64(encoded_string))
end