Class: Dragonfly::ScpDataStore::DataStore

Inherits:
Object
  • Object
show all
Includes:
Configurable
Defined in:
lib/dragonfly/scp_data_store.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ DataStore



18
19
20
21
22
23
24
# File 'lib/dragonfly/scp_data_store.rb', line 18

def initialize(options = {})
  self.host = options[:host]
  self.username = options[:username]
  self.password = options[:password]
  self.folder = options[:folder]
  self.base_url = options[:base_url]
end

Instance Method Details

#destroy(uid) ⇒ Object

Raises:

  • (DataNotFound)


45
46
47
# File 'lib/dragonfly/scp_data_store.rb', line 45

def destroy(uid)
  raise DataNotFound
end

#retrieve(uid) ⇒ Object



34
35
36
37
38
39
40
41
42
43
# File 'lib/dragonfly/scp_data_store.rb', line 34

def retrieve(uid)
  uri = URI(base_url + uid)
  response = Net::HTTP.get_response(uri)

  if response.is_a? Net::HTTPSuccess
    [response.body, { }]
  else
    raise DataNotFound
  end
end

#store(temp_object, opts = {}) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/dragonfly/scp_data_store.rb', line 26

def store(temp_object, opts={})
  uid = generate_uid(temp_object.name || 'file')

  process_file(temp_object.file.path, uid)

  uid
end