# code: # * George Moschovitis # # (c) 2004 Navel, all rights reserved. # $Id: requestpart.rb 112 2004-10-27 10:59:55Z gmosx $ require "cgi" require "ftools" require "n/utils/string" require "n/utils/uri" require "n/utils/http" require "n/server/cookie" module N # RequestPart # # This class encapsulates a part in a multipart request. # A part is typically an uploaded files. # class RequestPart # the filename of the part attr_accessor :filename # the original filename path attr_accessor :original_path # the temp filename path attr_accessor :body # the content-type attr_accessor :content_type def initialize(original_path, body, content_type = nil) @original_path = original_path @body = body @content_type = content_type # handle dos + unix separators. @filename = @original_path.split(/\/|\\/).last end # gmosx: # Hack fixed save for webrick! # def save(prefix, forced_filename = nil, forced_extension = nil) ::FileUtils.mkdir_p(prefix) save_path = "#{prefix}/#{@filename}" ::File.open(save_path, "wb") {|f| f.write @body } return save_path end end end # module