Browse Source

Read file (#2689)

pull/2685/head
kosiakkatrina 3 months ago committed by GitHub
parent
commit
ce91547733
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      app/services/collection_resources_service.rb
  2. 2
      app/services/storage/local_disk_service.rb
  3. 5
      app/services/storage/s3_service.rb

2
app/services/collection_resources_service.rb

@ -8,7 +8,7 @@ class CollectionResourcesService
end
def get_file(file)
@storage_service.get_file_io(file)
@storage_service.get_file(file)
rescue StandardError
nil
end

2
app/services/storage/local_disk_service.rb

@ -7,7 +7,7 @@ module Storage
Dir.entries(path)
end
def get_file_io(filename)
def get_file(filename)
path = Rails.root.join("tmp/storage", filename)
File.open(path, "r")

5
app/services/storage/s3_service.rb

@ -31,6 +31,11 @@ module Storage
.body
end
def get_file(file_name)
@client.get_object(bucket: @configuration.bucket_name, key: file_name)
.body.read
end
def write_file(file_name, data)
@client.put_object(
body: data,

Loading…
Cancel
Save