gooddata_s3 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gooddata_s3/client.rb +28 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf21433f8b5c3aa67545ac281ed48d0718c81cf2
|
4
|
+
data.tar.gz: e003a0fe9b34af3e586fe4efd26eb80654a873bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61ccf70b048d8d9dfd963ea7cb7eaa60d714e18c383dd5839281a63b398fb01a391230c5f1e5a88814f778648bd033443c6329b131ce56ef00ea7ab81026335c
|
7
|
+
data.tar.gz: 0bc85e02ba1bfe189ab0e7b9c9c230d400904dee38e323f67c924d5da74b9d7f584d0c9bca93eefa79c1b11647598f5771c4325405384fb1132e7b5b81d2b013
|
data/lib/gooddata_s3/client.rb
CHANGED
@@ -26,15 +26,34 @@ class GoodDataS3::Client
|
|
26
26
|
|
27
27
|
@s3 = AWS::S3::Client.new(region: 'us-east-1')
|
28
28
|
|
29
|
-
|
29
|
+
begin
|
30
|
+
|
31
|
+
bucket_exists = @s3.list_buckets.include? @bucket_name
|
32
|
+
|
33
|
+
if bucket_exists == false
|
34
|
+
bucket = @s3.create_bucket(:bucket_name => @bucket_name)
|
35
|
+
else
|
36
|
+
bucket = bucket_exists
|
37
|
+
end
|
38
|
+
|
39
|
+
rescue Exception => exp
|
40
|
+
puts "#{Time.now} => Attempted to list all buckets, recieved: #{exp}"
|
41
|
+
puts "#{Time.now} => Failed to access all buckets and/or create bucket, ensuring minimal write acccess to \"#{@bucket_name}\""
|
42
|
+
|
43
|
+
# Create and upload test file.
|
44
|
+
test_access_file = SecureRandom.hex
|
45
|
+
puts "#{Time.now} Creating test file \"#{test_access_file}\""
|
46
|
+
file = File.open(test_access_file, 'w+')
|
47
|
+
file.puts 'test'
|
48
|
+
self.upload(test_access_file)
|
49
|
+
|
50
|
+
# Remove test file from remote and local
|
51
|
+
self.delete(test_access_file)
|
52
|
+
file = File.delete(test_access_file) if File.exists?(test_access_file)
|
30
53
|
|
31
|
-
if bucket_exists == false
|
32
|
-
bucket = @s3.create_bucket(:bucket_name => @bucket_name)
|
33
|
-
else
|
34
|
-
bucket = bucket_exists
|
35
54
|
end
|
36
55
|
|
37
|
-
puts "#{Time.now} =>
|
56
|
+
puts "#{Time.now} => Sucessfully authenticated read/write to S3 Bucket: \"#{@bucket_name}\""
|
38
57
|
unless @directories.empty?
|
39
58
|
puts "#{Time.now} => Assigned default directory location: \"#{@directories.join('/')}\""
|
40
59
|
end
|
@@ -213,7 +232,7 @@ class GoodDataS3::Client
|
|
213
232
|
|
214
233
|
alias :include? :exists?
|
215
234
|
|
216
|
-
def delete file_path
|
235
|
+
def delete file_path, config = {}
|
217
236
|
|
218
237
|
begin
|
219
238
|
|
@@ -236,6 +255,8 @@ class GoodDataS3::Client
|
|
236
255
|
|
237
256
|
end
|
238
257
|
|
258
|
+
key = "/#{key}" unless key[0] == '/'
|
259
|
+
|
239
260
|
puts "#{Time.now} => Deleting from S3 Bucket (#{@bucket_name}): \"#{key}\""
|
240
261
|
@s3.delete_object(bucket_name: @bucket_name, key: key)
|
241
262
|
|