capriza-aws 0.0.9 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/capriza-aws/version.rb +1 -1
- data/lib/capriza-aws.rb +28 -8
- metadata +2 -2
data/lib/capriza-aws/version.rb
CHANGED
data/lib/capriza-aws.rb
CHANGED
@@ -15,7 +15,7 @@ module Capriza
|
|
15
15
|
AWS.config(@config)
|
16
16
|
end
|
17
17
|
|
18
|
-
def validate
|
18
|
+
def validate s
|
19
19
|
if @config.kind_of?(String) and File.exist?(config_file)
|
20
20
|
if File.exist?(config_file)
|
21
21
|
self.read_config_file(@config)
|
@@ -23,13 +23,13 @@ module Capriza
|
|
23
23
|
raise "Config file #{config_file} not found"
|
24
24
|
end
|
25
25
|
elsif @config.kind_of?(Hash)
|
26
|
-
|
27
|
-
|
26
|
+
puts @config
|
27
|
+
unless @config.has_key?('access_key_id') and @config.has_key?('secret_access_key') and @config.has_key?('s3_endpoint')
|
28
28
|
raise "Configuration missing. need the following " +
|
29
29
|
"access_key_id: YOUR_ACCESS_KEY_ID " +
|
30
|
-
"secret_access_key: YOUR_SECRET_ACCESS_KEY "
|
30
|
+
"secret_access_key: YOUR_SECRET_ACCESS_KEY " +
|
31
31
|
"s3_endpoint: YOUR_S3_ENDPOINT "
|
32
|
-
|
32
|
+
end
|
33
33
|
else
|
34
34
|
raise("Unrecognized Format. Config can be an filename or Hash.")
|
35
35
|
end
|
@@ -60,14 +60,14 @@ module Capriza
|
|
60
60
|
metadata = @obj.head[:metadata]
|
61
61
|
content_type = "application/zip"
|
62
62
|
@obj.copy_to(@obj.key, :metadata => metadata, :content_type => content_type)
|
63
|
-
@obj.acl = :public_read
|
63
|
+
@obj.acl = :public_read if make_public
|
64
64
|
end
|
65
65
|
|
66
66
|
def download()
|
67
67
|
@data = @obj.read
|
68
68
|
end
|
69
69
|
|
70
|
-
def set_metadata(key,value)
|
70
|
+
def set_metadata(key, value)
|
71
71
|
@obj.metadata[key] = value
|
72
72
|
end
|
73
73
|
|
@@ -79,11 +79,31 @@ module Capriza
|
|
79
79
|
unless File.exist?(local_file)
|
80
80
|
raise "File #{local_file} does not exist"
|
81
81
|
end
|
82
|
-
@obj.etag.gsub(/\"/,"") == Digest::MD5.hexdigest(File.read(local_file))
|
82
|
+
@obj.etag.gsub(/\"/, "") == Digest::MD5.hexdigest(File.read(local_file))
|
83
83
|
end
|
84
84
|
|
85
85
|
end
|
86
86
|
|
87
87
|
end
|
88
88
|
|
89
|
+
class S3upload
|
90
|
+
def initialize(bucket, folder_name, config, make_public = false)
|
91
|
+
S3connect.new(config)
|
92
|
+
s3 = AWS::S3.new()
|
93
|
+
|
94
|
+
b = s3.buckets[bucket_name]
|
95
|
+
|
96
|
+
Dir.foreach(folder_name) do |item|
|
97
|
+
next if item == '.' or item == '..'
|
98
|
+
|
99
|
+
basename = File.basename(item)
|
100
|
+
o = b.objects[basename]
|
101
|
+
o.write(:file => item)
|
102
|
+
o.acl = :public_read if make_public
|
103
|
+
puts item
|
104
|
+
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
108
|
+
end
|
89
109
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capriza-aws
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aws-sdk
|