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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/gooddata_s3/client.rb +28 -7
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3008837b2c97e8eef0f74a6df411dcdacf1f7d52
4
- data.tar.gz: c42602c488fdb20c853e8f9c316085339ff133de
3
+ metadata.gz: bf21433f8b5c3aa67545ac281ed48d0718c81cf2
4
+ data.tar.gz: e003a0fe9b34af3e586fe4efd26eb80654a873bb
5
5
  SHA512:
6
- metadata.gz: a2dcfb85141f8ef2199f03e73ee3a0246d408f0f605f5d976a1f80e8ff2fc178552104b72708f435cddb13f120bc38377c288bca9a278abc6a677d0c42ab55f8
7
- data.tar.gz: 698505440bc89495c108fbb1b62a4b1136f496e4c44945776c6c7ae6bedc0aa6774e08cb9e039ffdd87fcbbaa5968fb477b54f4c80dcd583adf55c43b21bfa33
6
+ metadata.gz: 61ccf70b048d8d9dfd963ea7cb7eaa60d714e18c383dd5839281a63b398fb01a391230c5f1e5a88814f778648bd033443c6329b131ce56ef00ea7ab81026335c
7
+ data.tar.gz: 0bc85e02ba1bfe189ab0e7b9c9c230d400904dee38e323f67c924d5da74b9d7f584d0c9bca93eefa79c1b11647598f5771c4325405384fb1132e7b5b81d2b013
@@ -26,15 +26,34 @@ class GoodDataS3::Client
26
26
 
27
27
  @s3 = AWS::S3::Client.new(region: 'us-east-1')
28
28
 
29
- bucket_exists = @s3.list_buckets.include? @bucket_name
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} => Connected to S3 Bucket: \"#{@bucket_name}\""
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gooddata_s3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick McConlogue