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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 806dbb2a9821958ce5b6d32219023f671ea6119e837ae1de29753a6d5acf4ce2
4
- data.tar.gz: 2ff4c8cafe89cb3169dc44d0feaa8ea77268ad109213f58bede51a0a0c65ffd9
3
+ metadata.gz: e3e776ef35e7b2dc7c1a9e1cc20d931ecec09bebe00abce098644da697b50738
4
+ data.tar.gz: 0e74d753a882b403edaf0ab8f1bd8da77b4f7ebae18abb0f96e56567bc660818
5
5
  SHA512:
6
- metadata.gz: ea6d083e9e2b7f1907c019ac450232cb33cd0c060b0f71aa23a84099b9d45f8b476458598d2be36d9d4061da88f8b702cc9e8fbfcc38dd50446198d2f2741f22
7
- data.tar.gz: 553ca24e53f1a98b30a782ae58d2a0005139675e1f6de23f6d2b0dae2d92553de690b6eb5642d6567204890c59a4be8ec1c15eff868963264951271b0c2c0cda
6
+ metadata.gz: 000d1fbda9b863ec5fe30424a8897a749f275eb7350d6c9c11ac4dc91409b9fc59bc9028d4f3a98b03e43455a900844ee291bcc35c993d733549d8196b0fee36
7
+ data.tar.gz: 398629554803738dfba8b7aad596bbf7013dba43863f653237563fdd4581977884e2e19fa44b53ff1882791f88eb1ef9e103c6ffbb7cadbdf745aab66027dd92
@@ -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:, base64: false)
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']}&tstamp=#{file.mtime}"
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?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uc3DmpS3
4
- VERSION = '0.0.4'
4
+ VERSION = '0.0.6'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uc3-dmp-s3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Riley