-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapplication.rb
49 lines (39 loc) · 1.26 KB
/
application.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
require 'aws/s3'
class Application < Rhoconnect::Base
include AWS::S3
class << self
def authenticate(username,password,session)
true # do some interesting authentication here...
end
def initializer(path)
super
# clean_amazon_storage
end
def clean_amazon_storage
AWS::S3::Base.establish_connection!(
:access_key_id => ENV['AMAZON_ACCESS_KEY_ID'],
:secret_access_key => ENV['AMAZON_SECRET_ACCESS_KEY']
)
# AWS::S3::Bucket.create('rhodes-store-bulk-blobs')
# AWS::S3::Bucket.create('rhodes-store-bulk-blobs-scheme')
# bucket = 'rhodes-system-samples-images-auto'
AWS::S3::Bucket.find('rhodes-store-bulk-blobs').objects.each do |entry|
puts "Found: #{entry.inspect}"
AWS::S3::S3Object.delete entry.key, 'rhodes-store-bulk-blobs'
end
AWS::S3::Bucket.find('rhodes-store-bulk-blobs-scheme').objects.each do |entry|
puts "Found: #{entry.inspect}"
AWS::S3::S3Object.delete entry.key, 'rhodes-store-bulk-blobs-scheme'
end
end
def store_blob(obj,field_name,blob)
puts "store_blob: obj=#{obj}, field_name=#{field_name}, blob=#{blob}"
if blob
obj['filename'] = blob[:filename]
obj['image_uri'] = blob[:tempfile].path
end
super
end
end
end
Application.initializer(ROOT_PATH)