diff options
author | Eric Wong <normalperson@yhbt.net> | 2011-12-09 18:22:01 -0800 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2011-12-10 02:24:57 +0000 |
commit | b69111a6573826d7c4fc3edd4fcc514d0eb425e9 (patch) | |
tree | 9fff6abac5a4fea6ed245583fd24456db5432fa7 /lib/mogilefs/mogilefs.rb | |
parent | 7f153071e40b1242ad0aa46c81ec0e927b9fc890 (diff) | |
download | mogilefs-client-b69111a6573826d7c4fc3edd4fcc514d0eb425e9.tar.gz |
Diffstat (limited to 'lib/mogilefs/mogilefs.rb')
-rw-r--r-- | lib/mogilefs/mogilefs.rb | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/lib/mogilefs/mogilefs.rb b/lib/mogilefs/mogilefs.rb index b192605..8a35168 100644 --- a/lib/mogilefs/mogilefs.rb +++ b/lib/mogilefs/mogilefs.rb @@ -125,16 +125,30 @@ class MogileFS::MogileFS < MogileFS::Client get_paths(key, *args).map! { |path| URI.parse(path) } end - # Creates a new file +key+ in +klass+. +bytes+ is currently unused. - # Consider using store_file instead of this method for large files. - # This requires a block passed to it and operates like File.open. - # This atomically replaces existing data stored as +key+ when + # Creates a new file +key+ in the domain of this object. + # + # +bytes+ is the expected size of the file if known in advance + # + # It operates like File.open(..., "w") and may take an optional + # block, yielding an IO-like object with support for the methods + # documented in MogileFS::NewFile::Writer. + # + # This atomically replaces existing data stored as +key+ + # when the block exits or when the returned object is closed. # # +args+ may contain the following options: - # * :content_length => Integer - # * :largefile => [ :stream, :content_range, :tempfile ] - # (see # MogileFS::NewFile) - # * :content_md5 => String, Proc, or :trailer + # + # [:content_length => Integer] + # + # This has the same effect as the (deprecated) +bytes+ parameter. + # + # [ :largefile => :stream, :content_range or :tempfile ] + # + # See MogileFS::NewFile for more information on this + # + # [ :class => String] + # + # The MogileFS storage class of the object. def new_file(key, args = nil, bytes = nil) # :yields: file raise MogileFS::ReadOnlyError if readonly? opts = { :key => key, :multi_dest => 1 } @@ -167,7 +181,7 @@ class MogileFS::MogileFS < MogileFS::Client case (dests[0][1] rescue nil) when %r{\Ahttp://} - http_file = MogileFS::NewFile[opts[:largefile]].new(dests, opts) + http_file = MogileFS::NewFile.new(dests, opts) if block_given? yield http_file return http_file.commit # calls create_close |