From 296977523d04e184b954f5a00e9463dea0d8e8d6 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 6 Dec 2011 20:54:07 +0000 Subject: store_file/store_content: wire these up to new new_file opts These allow us to specify Content-MD5 and checksums for use with the new and improved new_file interface without breaking existing apps. --- lib/mogilefs/mogilefs.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'lib/mogilefs/mogilefs.rb') 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 -- cgit v1.2.3-24-ge0c7