fix paths of large sized images on s3 backup
This commit is contained in:
@@ -20,7 +20,7 @@ protected
|
|||||||
when :preview
|
when :preview
|
||||||
"preview/#{File.basename(file_path)}"
|
"preview/#{File.basename(file_path)}"
|
||||||
when :large
|
when :large
|
||||||
"large/#{File.basename(file_path)}"
|
"sample/#{File.basename(file_path)}"
|
||||||
else
|
else
|
||||||
raise ArgumentError.new("Unknown type: #{type}")
|
raise ArgumentError.new("Unknown type: #{type}")
|
||||||
end
|
end
|
||||||
@@ -29,7 +29,7 @@ protected
|
|||||||
def upload_to_s3(key, file_path)
|
def upload_to_s3(key, file_path)
|
||||||
File.open(file_path, "rb") do |body|
|
File.open(file_path, "rb") do |body|
|
||||||
base64_md5 = Digest::MD5.base64digest(File.read(file_path))
|
base64_md5 = Digest::MD5.base64digest(File.read(file_path))
|
||||||
client.put_object(bucket: bucket, key: key, body: body, content_md5: base64_md5)
|
client.put_object(acl: "public-read", bucket: bucket, key: key, body: body, content_md5: base64_md5)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ class AmazonBackup < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
if File.exists?(post.large_file_path)
|
if File.exists?(post.large_file_path)
|
||||||
key = "large/#{post.md5}.#{post.large_file_ext}"
|
key = "sample/#{post.md5}.#{post.large_file_ext}"
|
||||||
body = open(post.large_file_path, "rb")
|
body = open(post.large_file_path, "rb")
|
||||||
client.put_object(bucket: bucket, key: key, body: body)
|
client.put_object(bucket: bucket, key: key, body: body)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user