Class: MultiSync::AwsTarget
- Inherits:
-
Target
- Object
- Target
- MultiSync::AwsTarget
show all
- Defined in:
- lib/multi_sync/targets/aws_target.rb
Instance Method Summary
collapse
Methods inherited from Target
#initialize
Instance Method Details
#delete(resource) ⇒ Object
53
54
55
56
57
58
|
# File 'lib/multi_sync/targets/aws_target.rb', line 53
def delete(resource)
MultiSync.debug "Delete #{resource} '#{resource.path_without_root}' from #{self} '/#{target_dir + destination_dir}'"
connection.delete_object(target_dir.to_s, (destination_dir + resource.path_without_root).to_s)
resource
end
|
#files ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/multi_sync/targets/aws_target.rb', line 10
def files
files = []
directory = connection.directories.get(target_dir.to_s, prefix: destination_dir.to_s)
return files if directory.nil?
directory.files.each { |file|
pathname = Pathname.new(file.key)
next unless valid_path?(pathname)
files << MultiSync::RemoteResource.new(
file: file,
path_with_root: target_dir + pathname, path_without_root: destination_dir != '' ? pathname.relative_path_from(destination_dir).cleanpath : pathname
)
}
files.sort
end
|
#upload(resource) ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/multi_sync/targets/aws_target.rb', line 31
def upload(resource)
MultiSync.debug "Upload #{resource} '#{resource.path_without_root}' to #{self} '/#{target_dir + destination_dir}'"
directory = connection.directories.get(target_dir.to_s)
return if directory.nil?
upload_hash = {
key: (destination_dir + resource.path_without_root).to_s,
body: resource.body,
content_type: resource.content_type,
content_md5: Digest::MD5.base64digest(resource.body)
}
MultiSync::Resource::AWS_ATTRIBUTES.each do |attribute_hash|
upload_hash[attribute_hash[:name]] = resource.send(attribute_hash[:name])
end
directory.files.create(upload_hash)
resource
end
|