# Copyright: Copyright (c) 2004 Nicolas Despres. All rights reserved. # Author: Nicolas Despres . # License: Gnu General Public License. # $LastChangedBy: polrop $ # $Id: fetcher.rb 67 2004-12-07 01:00:10Z polrop $ require 'md5' module Session module Fetcher # # Requests # def upload(local_filename, remote_filename) ret = false File.open(local_filename, 'r') do |f| md5 = Digest::MD5.new local_eof = false ret = request(:fetch, remote_filename, 'w') do if f.eof? unless local_eof local_eof = true nil else md5 end else str = f.read(1024) md5 << str str end end end ret end def download(remote_filename, local_filename) ret = false File.open(local_filename, 'w') do |f| md5 = Digest::MD5.new ret = request(:fetch, remote_filename) do |str| if str.nil? md5 else md5 << str f.write(str) end end end ret end end # Fetcher end # module Session