def write(*args, &block)
options = args.pop if Hash === args.last
options ||= {}
if String === args.first
ios = StringIO.new(args.first, 'r')
write(options.merge(:size=>args.first.size)) { |bytes| ios.read(bytes) }
elsif args.first.respond_to?(:read)
size = args.first.size rescue nil
write({:size=>size}.merge(options)) { |bytes| args.first.read(bytes) }
elsif args.empty? && block
write_internal options, &block
else
raise ArgumentError, 'Either give me the content, or pass me a block, otherwise what would I upload?'
end
end