potential fix for #3604

This commit is contained in:
Albert Yi
2018-04-06 16:14:01 -07:00
parent 5a87fcfde3
commit fc344e589d

View File

@@ -23,21 +23,25 @@ class StorageManager::S3 < StorageManager
super(**options) super(**options)
end end
def key(path)
path.sub(/^.+?data\//, "")
end
def store(io, path) def store(io, path)
data = io.read data = io.read
base64_md5 = Digest::MD5.base64digest(data) 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 end
def delete(path) def delete(path)
client.delete_object(bucket: bucket, key: path) client.delete_object(bucket: bucket, key: key(path))
rescue Aws::S3::Errors::NoSuchKey rescue Aws::S3::Errors::NoSuchKey
# ignore # ignore
end end
def open(path) def open(path)
file = Tempfile.new(binmode: true) 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 file
end end
end end