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

- old
+ new

@@ -24,10 +24,14 @@ raise 'not logged in' unless login? options = Options.new(options) Dir.mktmpdir do |dir| - upload_filename = (Pathname(dir) + ([Time.now.to_f.to_s, Digest::MD5.hexdigest(filename).to_s].join('_'))).to_s + upload_filename = (Pathname(dir) + ([ + Time.now.to_f.to_s, + Digest::MD5.hexdigest(filename).to_s, + File.basename(filename).gsub(/[^\w]+/, '') + File.extname(filename) + ].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