diff options
Diffstat (limited to 'lib/mogilefs/put/tempfile.rb')
-rw-r--r-- | lib/mogilefs/put/tempfile.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/mogilefs/put/tempfile.rb b/lib/mogilefs/put/tempfile.rb new file mode 100644 index 0000000..8082f95 --- /dev/null +++ b/lib/mogilefs/put/tempfile.rb @@ -0,0 +1,24 @@ +# -*- encoding: binary -*- +# here are internal implementation details, do not rely on them in your code +require 'tempfile' +require 'mogilefs/http_file' + +class MogileFS::Put::Tempfile < Tempfile + def initialize(*args) + @mogilefs_httpfile_args = args + super("mogilefs-client") + unlink + end + + def commit + rewind + tmp = MogileFS::HTTPFile.new(*@mogilefs_httpfile_args) + tmp.big_io = to_io + tmp.commit + end + + def close + commit + super + end +end |