uc3-dmp-s3 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/uc3-dmp-s3/client.rb +16 -0
- data/lib/uc3-dmp-s3/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 806dbb2a9821958ce5b6d32219023f671ea6119e837ae1de29753a6d5acf4ce2
|
4
|
+
data.tar.gz: 2ff4c8cafe89cb3169dc44d0feaa8ea77268ad109213f58bede51a0a0c65ffd9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea6d083e9e2b7f1907c019ac450232cb33cd0c060b0f71aa23a84099b9d45f8b476458598d2be36d9d4061da88f8b702cc9e8fbfcc38dd50446198d2f2741f22
|
7
|
+
data.tar.gz: 553ca24e53f1a98b30a782ae58d2a0005139675e1f6de23f6d2b0dae2d92553de690b6eb5642d6567204890c59a4be8ec1c15eff868963264951271b0c2c0cda
|
data/lib/uc3-dmp-s3/client.rb
CHANGED
@@ -19,10 +19,26 @@ module Uc3DmpS3
|
|
19
19
|
#
|
20
20
|
class Client
|
21
21
|
NARRATIVE_KEY_PREFIX = 'narratives/'
|
22
|
+
RESOURCE_KEY_PREFIX = 'external_resources/'
|
22
23
|
|
23
24
|
MSG_S3_FAILURE = 'Unable to save the object at this time'
|
24
25
|
|
25
26
|
class << self
|
27
|
+
# Put the narrative file into the S3 bucket
|
28
|
+
def put_resource_file(file:, explorer_details:, base64: false)
|
29
|
+
return nil if File.nil? || !explorer_details.is_a?(Hash) || ENV['S3_BUCKET'].nil? ||
|
30
|
+
explorer_details.fetch('file_metadata', {})['filename'].nil?
|
31
|
+
|
32
|
+
filename = "#{explorer_details['ID']}_#{explorer_details['file_metadata']['filename']}"
|
33
|
+
key = "#{RESOURCE_KEY_PREFIX}#{filename}"
|
34
|
+
tg = "RESOURCE_TYPE=#{explorer_details['RESOURCE_TYPE']}&ID=#{explorer_details['ID']}&tstamp=#{file.mtime}"
|
35
|
+
|
36
|
+
_put_object(key:, tags: tg, payload: file)
|
37
|
+
rescue Aws::Errors::ServiceError => e
|
38
|
+
msg = "Unable to write External Resource file to S3 bucket (#{tg})"
|
39
|
+
raise ClientError, "#{msg} - #{e.message}"
|
40
|
+
end
|
41
|
+
|
26
42
|
# Put the narrative file into the S3 bucket
|
27
43
|
def put_narrative(document:, dmp_id: nil, base64: false)
|
28
44
|
return nil if !document.is_a?(String) || document.strip.empty? || ENV['S3_BUCKET'].nil?
|
data/lib/uc3-dmp-s3/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uc3-dmp-s3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Riley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-10-
|
11
|
+
date: 2023-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-s3
|