uc3-dmp-s3 0.0.4 → 0.0.6
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 +11 -2
- data/lib/uc3-dmp-s3/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3e776ef35e7b2dc7c1a9e1cc20d931ecec09bebe00abce098644da697b50738
|
4
|
+
data.tar.gz: 0e74d753a882b403edaf0ab8f1bd8da77b4f7ebae18abb0f96e56567bc660818
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 000d1fbda9b863ec5fe30424a8897a749f275eb7350d6c9c11ac4dc91409b9fc59bc9028d4f3a98b03e43455a900844ee291bcc35c993d733549d8196b0fee36
|
7
|
+
data.tar.gz: 398629554803738dfba8b7aad596bbf7013dba43863f653237563fdd4581977884e2e19fa44b53ff1882791f88eb1ef9e103c6ffbb7cadbdf745aab66027dd92
|
data/lib/uc3-dmp-s3/client.rb
CHANGED
@@ -25,13 +25,13 @@ module Uc3DmpS3
|
|
25
25
|
|
26
26
|
class << self
|
27
27
|
# Put the narrative file into the S3 bucket
|
28
|
-
def put_resource_file(file:, explorer_details
|
28
|
+
def put_resource_file(file:, explorer_details:)
|
29
29
|
return nil if File.nil? || !explorer_details.is_a?(Hash) || ENV['S3_BUCKET'].nil? ||
|
30
30
|
explorer_details.fetch('file_metadata', {})['filename'].nil?
|
31
31
|
|
32
32
|
filename = "#{explorer_details['ID']}_#{explorer_details['file_metadata']['filename']}"
|
33
33
|
key = "#{RESOURCE_KEY_PREFIX}#{filename}"
|
34
|
-
tg = "RESOURCE_TYPE=#{explorer_details['RESOURCE_TYPE']}&ID=#{explorer_details['ID']}
|
34
|
+
tg = "RESOURCE_TYPE=#{explorer_details['RESOURCE_TYPE']}&ID=#{explorer_details['ID']}"
|
35
35
|
|
36
36
|
_put_object(key:, tags: tg, payload: file)
|
37
37
|
rescue Aws::Errors::ServiceError => e
|
@@ -39,6 +39,15 @@ module Uc3DmpS3
|
|
39
39
|
raise ClientError, "#{msg} - #{e.message}"
|
40
40
|
end
|
41
41
|
|
42
|
+
# Fetch the narrative file from the S3 bucket
|
43
|
+
def get_resource_file(key:)
|
44
|
+
return nil unless key.is_a?(String) && !key.strip.empty? && !ENV['S3_BUCKET'].nil?
|
45
|
+
|
46
|
+
obj = _get_object(key: key.start_with?(RESOURCE_KEY_PREFIX) ? key : "#{RESOURCE_KEY_PREFIX}#{key}")
|
47
|
+
rescue Aws::Errors::ServiceError => e
|
48
|
+
raise ClientError, "Unable to fetch External Resource file from S3 bucket (key: #{key}) - #{e.message}"
|
49
|
+
end
|
50
|
+
|
42
51
|
# Put the narrative file into the S3 bucket
|
43
52
|
def put_narrative(document:, dmp_id: nil, base64: false)
|
44
53
|
return nil if !document.is_a?(String) || document.strip.empty? || ENV['S3_BUCKET'].nil?
|
data/lib/uc3-dmp-s3/version.rb
CHANGED