outreach_gem 1.0.48 → 1.0.56

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e2df1cd2c5d1aed81ffc4542db07b6d9ba7497a5f320a1f65fac4b0ef51cfd69
4
- data.tar.gz: d80a4b6b1abd07632f198083628806686bfa2fc1dfe27ab1edda8e5a2e905974
3
+ metadata.gz: '028f837f523d49ef1ec685b2192be60685057045495fda1f6c934b888cb44853'
4
+ data.tar.gz: 00fe634ca1cf2d7f25226a36424f35daee50123a0f943372fefaab935581f2ad
5
5
  SHA512:
6
- metadata.gz: 9247df0cb2d4d6ee5aafcb6ffe3fbd4ba22519bb790f6b303495ba2d8ccfe48d856037e5f8b245b959b8723c1f07aa719970f9cacfcdd99b19911879e8e8411f
7
- data.tar.gz: a0a3fa8d20e2880b210b018c503e6989731adee1245c0c1a57ffcf8acc7820968fc86db0c370b3187c93fc4027712d0f3a86e286ab5008bb7ae70f4aba3e986f
6
+ metadata.gz: 19088ea39d4ca3a43d4b0fbeda9610282fef9ad41b453fb950afe37e861dcf057a64ceafa4c9c0d64216e11e4ad175331c83647f5aba58233153b03f2cd0282e
7
+ data.tar.gz: 5cb67ab49b1d2c9277027d1ef8b2cb14badcdfeb8142ec6ad74f670591eb31181410c8f89a5821495daae17bbbcdc16fdd3bae599d4eedb52f19d4b7c5e55fbe
@@ -0,0 +1,79 @@
1
+ require 'aws-sdk-s3'
2
+
3
+ class OutreachUploadS3
4
+
5
+ # @param key [String] Name of the key used to access AWS
6
+ # @param secret [String] Name of the secret key used to access AWS
7
+ # @param region [String] Name of the region of the bucket
8
+ # @param bucketName [String] Name of the S3 Bucket
9
+ def initialize(key, secretKey, region, bucketName)
10
+ if secretKey.empty?
11
+ raise 'secretKey cannot be empty'
12
+ end
13
+
14
+ if key.empty?
15
+ raise 'key cannot be empty'
16
+ end
17
+
18
+ if region.empty?
19
+ raise 'region cannot be empty'
20
+ end
21
+
22
+ if bucketName.empty?
23
+ raise 'bucketName cannot be empty'
24
+ end
25
+ @region = region
26
+ @bucketName = bucketName
27
+
28
+ Aws.config.update({
29
+ credentials: Aws::Credentials.new(key, secretKey)
30
+ })
31
+ @s3_client = Aws::S3::Client.new({
32
+ region: @region,
33
+ access_key_id: key,
34
+ secret_access_key: secretKey
35
+ })
36
+ end
37
+
38
+ # @param path [String] path to the file that needs to be uploaded
39
+ # @param key [String] the name of the object to upload
40
+ def uploadFile(path, key)
41
+ content = File.read path
42
+ obj = @s3_client.put_object({
43
+ body: content,
44
+ bucket: @bucketName,
45
+ key: key
46
+ })
47
+ return obj
48
+ end
49
+
50
+ # Retrieve an item from S3
51
+ # @param [string] The key representing the item in the bucket
52
+ # @return [S3Object] Return the S3 Object if it exists, if not then nil
53
+ def getItem(item_name)
54
+ if item_name.nil? or item_name.empty?
55
+ raise 'Cannot have an empty or nil item to retrieve from S3'
56
+ end
57
+ object = @s3_client.get_object(bucket: @bucketName, key: item_name)
58
+ if object.nil?
59
+ return nil
60
+ end
61
+ return object
62
+ end
63
+
64
+ # Delete the S3Object
65
+ # @param s3_object [S3Object] Delete the S3 Object from the bucket
66
+ # @raise RuntimeError object cannot be nil
67
+ def deleteFile(key)
68
+ result = @s3_client.delete_object({
69
+ bucket: @bucketName,
70
+ key: key
71
+ })
72
+ return result
73
+ end
74
+
75
+ # Delete the content of the entire bucket
76
+ def clearBucket()
77
+ Aws::S3::Resource.new(region:@region).bucket(@bucketName).clear!
78
+ end
79
+ end
data/lib/outreach_gem.rb CHANGED
@@ -3,4 +3,7 @@ require_relative 'helpers/helpers'
3
3
 
4
4
  # Used to perform restful services in Ruby
5
5
  require_relative 'rest-client/restfulclient'
6
- require_relative 'rest-client/resttype'
6
+ require_relative 'rest-client/resttype'
7
+
8
+ # Used to perform invocations to Amazon S3 in Ruby
9
+ require_relative 'outreach-s3/ruby-upload-s3'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: outreach_gem
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.48
4
+ version: 1.0.56
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrique Legault
@@ -17,6 +17,7 @@ extensions: []
17
17
  extra_rdoc_files: []
18
18
  files:
19
19
  - lib/helpers/helpers.rb
20
+ - lib/outreach-s3/ruby-upload-s3.rb
20
21
  - lib/outreach_gem.rb
21
22
  - lib/rest-client/restfulclient.rb
22
23
  - lib/rest-client/resttype.rb