lib/netprint/agent.rb in netprint-0.0.4 vs lib/netprint/agent.rb in netprint-0.1.0

- old
+ new

@@ -1,9 +1,10 @@ # -*- coding: utf-8 -*- require "tmpdir" require "fileutils" require "pathname" +require 'digest/md5' module Netprint class Agent attr_reader :userid, :password @@ -23,10 +24,10 @@ raise 'not logged in' unless login? options = Options.new(options) Dir.mktmpdir do |dir| - upload_filename = (Pathname(dir) + ([Time.now.to_f.to_s, File.basename(filename)].join('_'))).to_s + upload_filename = (Pathname(dir) + ([Time.now.to_f.to_s, Digest::MD5.hexdigest(filename).to_s].join('_'))).to_s cp filename, upload_filename page = mechanize.get(url.upload) page = page.form_with(:name => 'uploadform') do |form| form.file_uploads.first.file_name = upload_filename