From fc344e589def416bd51c4588865e2f1490ac5a84 Mon Sep 17 00:00:00 2001 From: Albert Yi Date: Fri, 6 Apr 2018 16:14:01 -0700 Subject: [PATCH] potential fix for #3604 --- app/logical/storage_manager/s3.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/logical/storage_manager/s3.rb b/app/logical/storage_manager/s3.rb index 08e8fad1c..43020d822 100644 --- a/app/logical/storage_manager/s3.rb +++ b/app/logical/storage_manager/s3.rb @@ -23,21 +23,25 @@ class StorageManager::S3 < StorageManager super(**options) end + def key(path) + path.sub(/^.+?data\//, "") + end + def store(io, path) data = io.read base64_md5 = Digest::MD5.base64digest(data) - client.put_object(bucket: bucket, key: path, body: data, content_md5: base64_md5, **DEFAULT_PUT_OPTIONS) + client.put_object(bucket: bucket, key: key(path), body: data, content_md5: base64_md5, **DEFAULT_PUT_OPTIONS) end def delete(path) - client.delete_object(bucket: bucket, key: path) + client.delete_object(bucket: bucket, key: key(path)) rescue Aws::S3::Errors::NoSuchKey # ignore end def open(path) file = Tempfile.new(binmode: true) - client.get_object(bucket: bucket, key: path, response_target: file) + client.get_object(bucket: bucket, key: key(path), response_target: file) file end end