Module: Paperclip::Storage::SwiftSwauth
- Defined in:
- lib/paperclip/storage/swift_swauth.rb
Class Method Summary collapse
-
.extended(base) ⇒ Object
Public: Hook for the base class to run.
Instance Method Summary collapse
-
#copy_to_local_file(style, local_dest_path) ⇒ Object
Public: Performs the delete operations stored in the delete queue.
-
#exists?(style = default_style) ⇒ Boolean
Public: Checks that the file exists.
-
#flush_deletes ⇒ Object
Public: Performs the delete operations stored in the delete queue.
-
#flush_writes ⇒ Object
Public: Performs the write operations stored in the write queue.
Class Method Details
.extended(base) ⇒ Object
Public: Hook for the base class to run
10 11 |
# File 'lib/paperclip/storage/swift_swauth.rb', line 10 def self.extended(base) end |
Instance Method Details
#copy_to_local_file(style, local_dest_path) ⇒ Object
Public: Performs the delete operations stored in the delete queue
style - The string which represents the file local_dest_path - The string which represents the location to save the file to
Examples
swift_swauth.copy_to_local_file('foo', '/path/to/foo')
=> nil
Returns nothing
70 71 72 73 74 75 76 |
# File 'lib/paperclip/storage/swift_swauth.rb', line 70 def copy_to_local_file(style, local_dest_path) if exists?(style) local_file = File.open(local_dest_path, 'wb') local_file.write(client.object(path(style)).data) local_file.close end end |
#exists?(style = default_style) ⇒ Boolean
Public: Checks that the file exists
style - The string which represents the file(default: default_style)
Examples
swift_swauth.exists 'foo'
=> true
Returns a Boolean
23 24 25 |
# File 'lib/paperclip/storage/swift_swauth.rb', line 23 def exists?(style=default_style) client.object_exists?(path(style)) end |
#flush_deletes ⇒ Object
Public: Performs the delete operations stored in the delete queue
Examples
swift_swauth.flush_deletes
=> []
Returns nothing
52 53 54 55 56 57 |
# File 'lib/paperclip/storage/swift_swauth.rb', line 52 def flush_deletes @queued_for_delete.each do |path| client.delete_object(path) if client.object_exists?(path) end @queue_for_delete = [] end |
#flush_writes ⇒ Object
Public: Performs the write operations stored in the write queue
Examples
swift_swauth.flush_writes
=> {}
Returns nothing
35 36 37 38 39 40 41 42 |
# File 'lib/paperclip/storage/swift_swauth.rb', line 35 def flush_writes @queued_for_write.each do |style, file| write_opts = { content_type: instance_read(:content_type) } client.create_object(path(style), write_opts, file) end after_flush_writes # allows attachment to clean up temp files @queued_for_write = {} end |