mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: use the right URL when downloading the file from S3
This commit is contained in:
parent
0b3d51a8bc
commit
14bbd5d167
@ -159,15 +159,17 @@ def migrate_from_s3
|
|||||||
begin
|
begin
|
||||||
if sha1 = Upload.sha1_from_short_url(url)
|
if sha1 = Upload.sha1_from_short_url(url)
|
||||||
if upload = Upload.find_by(sha1: sha1)
|
if upload = Upload.find_by(sha1: sha1)
|
||||||
file = FileHelper.download("http:#{url}", max_file_size: 20.megabytes, tmp_file_name: "from_s3", follow_redirect: true)
|
if upload.url.start_with?("//")
|
||||||
filename = upload.original_filename
|
file = FileHelper.download("http:#{upload.url}", max_file_size: 20.megabytes, tmp_file_name: "from_s3", follow_redirect: true)
|
||||||
origin = upload.origin
|
filename = upload.original_filename
|
||||||
upload.destroy
|
origin = upload.origin
|
||||||
|
upload.destroy
|
||||||
|
|
||||||
new_upload = UploadCreator.new(file, filename, origin: origin).create_for(post.user_id || -1)
|
new_upload = UploadCreator.new(file, filename, origin: origin).create_for(post.user_id || -1)
|
||||||
if new_upload&.save
|
if new_upload&.save
|
||||||
updated = true
|
updated = true
|
||||||
url = new_upload.url
|
url = new_upload.url
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user