Module | URI |
In: |
lib/buildr/core/transports.rb
(CVS)
|
Reads from the resource behind this URI. The first form returns the content of the resource, the second form yields to the block with each chunk of content (usually more than one).
For example:
File.open 'image.jpg', 'w' do |file| URI.read('http://example.com/image.jpg') { |chunk| file.write chunk } end
Shorter version:
File.open('image.jpg', 'w') { |file| file.write URI.read('http://example.com/image.jpg') }
Supported options:
Writes to the resource behind the URI. The first form writes the content from a string or an object that responds to read and optionally size. The second form writes the content by yielding to the block. Each yield should return up to the specified number of bytes, the last yield returns nil.
For example:
File.open 'killer-app.jar', 'rb' do |file| write('sftp://localhost/jars/killer-app.jar') { |chunk| file.read(chunk) } end
Or:
write 'sftp://localhost/jars/killer-app.jar', File.read('killer-app.jar')
Supported options: