class Metakiller

Public Class Methods

new(token) click to toggle source
# File lib/metakiller.rb, line 9
def initialize(token)
      @token = token
      @url = URI.parse("http://192.168.1.137:3000/#{@token}/clean")
end

Public Instance Methods

clean(filepath) click to toggle source
# File lib/metakiller.rb, line 14
def clean(filepath)
  File.open(filepath) do |file|
        req = Net::HTTP::Post::Multipart.new @url.path,
          "files[]" => UploadIO.new(file, getMime(filepath), File.basename(filepath))
        res = Net::HTTP.start(@url.host, @url.port) do |http|
          http.request(req)
        end
        return res.body
      end
end
getMime(filepath) click to toggle source
# File lib/metakiller.rb, line 25
def getMime(filepath)
      return MimeMagic.by_magic(File.open(filepath))
end