Method: MogileFS::MogileFS#store_file
- Defined in:
- lib/mogilefs/mogilefs.rb
#store_file(key, klass, file) ⇒ Object
Copies the contents of file into key in class klass. file can be either a file name or an object that responds to #read.
149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/mogilefs/mogilefs.rb', line 149 def store_file(key, klass, file) raise 'readonly mogilefs' if readonly? new_file key, klass do |mfp| if file.respond_to? :read then return copy(file, mfp) else return File.open(file) { |fp| copy(fp, mfp) } end end end |