outreach_gem 1.0.76 → 1.0.78

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: 9b0b936ecab7fd5b19e56247760573530f397eed4ddf064c6f578c383b5217e3
4
- data.tar.gz: 6b1583e48b2421ff5c5337bf615314537b938ffeaeea20e7876012ed2bdba36a
3
+ metadata.gz: 97ec8afa61b6beb80b50d295026341cb55967310995947653a99f12f69e78bd4
4
+ data.tar.gz: aaa53c5f11338054d5517b34a12ed7d9c7b540d52b3cc6b718f34210c8d47b5b
5
5
  SHA512:
6
- metadata.gz: 1ee5ddcb72645b2ea709ced1c7d0518e9a4906406276622aa73a563b83471dbd9d8f58e3bb08ebe5b8f92fecdab7271c1024d5034ac7fd412291720343f7e966
7
- data.tar.gz: 54c0813b6956d4b0b744f5f23ac402ea59ae2c4552c2091233ff96e5f67e2b982c3ae825e3c640b1b85dabac91d65ece79644e81c19ccbc8c105b19941e5de3b
6
+ metadata.gz: 11e7f9659e69f5f7f820bad4cbddb231e173619727beb0c955f2e51279258cdd5fc37ca2a93325feb54a4535fdf8dc7b9d4f27f3c9d4ea3d7761f5f7368ff056
7
+ data.tar.gz: a958b354c1d507853f94008f2cfc02b1f405db6b1ae0ee3e942b0e056bba389aa226e54d27a0e8270687006fdd143f8cbd3a7480e31c4d6ba984831ef8a9b4c4
@@ -41,16 +41,32 @@ class OutreachUploadS3
41
41
  })
42
42
  end
43
43
 
44
+ # When it comes to binary files you should be doing open then the read
45
+ # operations to it. Must not forget to close the file when performing
46
+ # an open operation on it.
44
47
  # @param path [String] path to the file that needs to be uploaded
45
48
  # @param key [String] the name of the object to upload
49
+ # @return obj [Hashes] the resulting object being returned from AWS S3
46
50
  def uploadFile(path, key)
47
- content = File.read path
48
- obj = @s3_client.put_object({
49
- body: content,
50
- bucket: @bucketName,
51
- key: key
52
- })
53
- return obj
51
+ if path.nil? or path.empty?
52
+ raise 'Cannot have an empty path when attempting to upload an object to AWS S3'
53
+ end
54
+
55
+ if key.nil? or key.empty?
56
+ raise 'Cannot have an empty key when uploading an Object to S3'
57
+ end
58
+
59
+ begin
60
+ # Open the file and get it ready to be read
61
+ file = File.open(path, 'rb')
62
+
63
+ # Stream the file into the S3 bucket
64
+ return @s3_client.put_object(bucket: @bucketName, key: key, body: file)
65
+ ensure
66
+ unless file.nil?
67
+ file.close
68
+ end
69
+ end
54
70
  end
55
71
 
56
72
  # Retrieve an item from S3 and return it in memory
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: outreach_gem
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.76
4
+ version: 1.0.78
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrique Legault
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-18 00:00:00.000000000 Z
11
+ date: 2019-08-08 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: patrique.legault@uottawa.ca