Class: Attachie::FileDriver::FileMultipartUpload
- Inherits:
-
Object
- Object
- Attachie::FileDriver::FileMultipartUpload
- Includes:
- MonitorMixin
- Defined in:
- lib/attachie/file_driver.rb
Instance Method Summary collapse
- #abort_upload ⇒ Object
- #complete_upload ⇒ Object
-
#initialize(name, bucket, driver, &block) ⇒ FileMultipartUpload
constructor
A new instance of FileMultipartUpload.
- #upload_part(data) ⇒ Object
Constructor Details
#initialize(name, bucket, driver, &block) ⇒ FileMultipartUpload
Returns a new instance of FileMultipartUpload.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/attachie/file_driver.rb', line 9 def initialize(name, bucket, driver, &block) super() @name = name @bucket = bucket @driver = driver @stream = open(driver.path_for(name, bucket), "wb") if block_given? begin block.call(self) rescue => e abort_upload raise e end complete_upload end end |
Instance Method Details
#abort_upload ⇒ Object
37 38 39 40 41 |
# File 'lib/attachie/file_driver.rb', line 37 def abort_upload @stream.close @target.delete(name, bucket) end |
#complete_upload ⇒ Object
43 44 45 |
# File 'lib/attachie/file_driver.rb', line 43 def complete_upload @stream.close end |
#upload_part(data) ⇒ Object
31 32 33 34 35 |
# File 'lib/attachie/file_driver.rb', line 31 def upload_part(data) synchronize do @stream.write(data) end end |