uc3-dmp-s3 0.0.3 → 0.0.4

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: c92a65afbb3240d8b8f8c743335c59f39251d969c9b4a68b2181af490fb08b62
4
- data.tar.gz: 39ea2a070012dac95f25a22e02941037fbc699e61705c5c0f277d1d70659f68d
3
+ metadata.gz: 806dbb2a9821958ce5b6d32219023f671ea6119e837ae1de29753a6d5acf4ce2
4
+ data.tar.gz: 2ff4c8cafe89cb3169dc44d0feaa8ea77268ad109213f58bede51a0a0c65ffd9
5
5
  SHA512:
6
- metadata.gz: 36e24653e806818a64ec7cee55eb97b95697e7aa277305ccb33cc6efe6c022fe04588c3d861669f021145264fc24175c7968e4b0b815662c6b2ed741a5430db9
7
- data.tar.gz: 9f834984c644f01f5a2c1b011ad49bdbe9c4a19889ebef49147c481795e7af34ee23788e441e40fc9bd1db789e3e954e98a2c6190779b579d410f37947dec122
6
+ metadata.gz: ea6d083e9e2b7f1907c019ac450232cb33cd0c060b0f71aa23a84099b9d45f8b476458598d2be36d9d4061da88f8b702cc9e8fbfcc38dd50446198d2f2741f22
7
+ data.tar.gz: 553ca24e53f1a98b30a782ae58d2a0005139675e1f6de23f6d2b0dae2d92553de690b6eb5642d6567204890c59a4be8ec1c15eff868963264951271b0c2c0cda
@@ -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?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uc3DmpS3
4
- VERSION = '0.0.3'
4
+ VERSION = '0.0.4'
5
5
  end
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.3
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-04 00:00:00.000000000 Z
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