diff options
author | Eric Wong <normalperson@yhbt.net> | 2011-12-06 20:54:07 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2011-12-06 13:09:02 -0800 |
commit | 296977523d04e184b954f5a00e9463dea0d8e8d6 (patch) | |
tree | a894a61d678201d14dee621044ae3efb647b87fc /lib/mogilefs/mogilefs.rb | |
parent | 2c4dc76c6a4840865c83177ceeb217b859e20df8 (diff) | |
download | mogilefs-client-296977523d04e184b954f5a00e9463dea0d8e8d6.tar.gz |
These allow us to specify Content-MD5 and checksums for use with the new and improved new_file interface without breaking existing apps.
Diffstat (limited to 'lib/mogilefs/mogilefs.rb')
-rw-r--r-- | lib/mogilefs/mogilefs.rb | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/mogilefs/mogilefs.rb b/lib/mogilefs/mogilefs.rb index 22dd39c..372eae0 100644 --- a/lib/mogilefs/mogilefs.rb +++ b/lib/mogilefs/mogilefs.rb @@ -181,18 +181,20 @@ class MogileFS::MogileFS < MogileFS::Client # either a path name (String or Pathname object) or an IO-like object that # responds to #read or #readpartial. Returns size of +file+ stored. # This atomically replaces existing data stored as +key+ - def store_file(key, klass, file) + def store_file(key, klass, file, opts = nil) raise MogileFS::ReadOnlyError if readonly? + (opts ||= {})[:class] = klass if String === klass - new_file(key, klass) { |mfp| mfp.big_io = file } + new_file(key, opts) { |mfp| mfp.big_io = file } end # Stores +content+ into +key+ in class +klass+, where +content+ is a String # This atomically replaces existing data stored as +key+ - def store_content(key, klass, content) + def store_content(key, klass, content, opts = nil) raise MogileFS::ReadOnlyError if readonly? + (opts ||= {})[:class] = klass if String === klass - new_file key, klass do |mfp| + new_file(key, opts) do |mfp| if content.is_a?(MogileFS::Util::StoreContent) mfp.streaming_io = content else |