Class: Tina4::FileUpload
- Inherits:
-
IndifferentHash
- Object
- Hash
- IndifferentHash
- Tina4::FileUpload
- Defined in:
- lib/tina4/request.rb
Overview
Per-file upload hash: indifferent access plus a lazily-materialised ‘content` field. The raw bytes are read from the tempfile only on first access to `content` (then rewound, so :tempfile streaming still works), so :tempfile-only handlers never buffer large uploads in memory.
Instance Method Summary collapse
Methods inherited from IndifferentHash
Instance Method Details
#[](key) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/tina4/request.rb', line 43 def [](key) if key.to_s == "content" && !key?("content") && (tf = super("tempfile")) self["content"] = begin tf.rewind if tf.respond_to?(:rewind) data = tf.read tf.rewind if tf.respond_to?(:rewind) data rescue StandardError nil end end super(key) end |