Class: CarrierWave::Swift::SwauthClient

Inherits:
Object
  • Object
show all
Defined in:
lib/carrierwave/swift/swauth_client.rb

Constant Summary collapse

SERVICE_TYPE =
'object-store'

Instance Method Summary collapse

Constructor Details

#initializeSwauthClient

Public: Constructor. Assumes all the needed variables are found in the environment



10
11
12
13
14
15
16
17
18
# File 'lib/carrierwave/swift/swauth_client.rb', line 10

def initialize
  @swift_opts = {
    user:      ENV['SWIFT_USER'] || '',
    password:  ENV['SWIFT_PASSWORD'] || '',
    url:       ENV['SWIFT_URL'] || '',
    tenant:    ENV['SWIFT_TENANT'] || '',
    container: ENV['SWIFT_CONTAINER'] || ''
  }
end

Instance Method Details

#create_object(path, opts = {}, data) ⇒ Object

Public: Creates the object given the path, options and data

path - The String which represents the object opts - The Hash which contains the options for the object data - The File or String which represents the data

Examples

swauth_client.create_object 'foo', {}, File.open('foo.pdf')
=> nil

Returns nothing



46
47
48
# File 'lib/carrierwave/swift/swauth_client.rb', line 46

def create_object(path, opts={}, data)
  container.create_object path, opts, data
end

#delete_object(path) ⇒ Object

Public: Deletes the object given the path

path - The String which represents the object

Examples

swauth_client.delete_object 'foo'
=> nil

Returns nothing



60
61
62
# File 'lib/carrierwave/swift/swauth_client.rb', line 60

def delete_object(path)
  container.delete_object path
end

#object(path) ⇒ Object

Public: Returns the object given the path

path - The String which represents the object

Examples

swauth_client.object 'foo'
=> <OpenStack::Swift::Container::Object>

Returns an instance of OpenStack::Swift::Container::Object



74
75
76
# File 'lib/carrierwave/swift/swauth_client.rb', line 74

def object(path)
  container.object path
end

#object_exists?(path) ⇒ Boolean

Public: Checks if the object exists in the container

path - The String which represents the object

Examples

swauth_client.object_exists 'foo'
=> true

Returns a Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/carrierwave/swift/swauth_client.rb', line 30

def object_exists?(path)
  container.object_exists? path
end