A platform for community discussion. Free, open, simple.
FIX: Use s3_endpoint in migrate_to_s3 when not using S3
Rishabhe69634ec3aa5
diff --git a/lib/tasks/uploads.rake b/lib/tasks/uploads.rakeindex 40b33e81e1c..6dc6c858c20 100644--- a/lib/tasks/uploads.rake+++ b/lib/tasks/uploads.rake@@ -246,10 +246,17 @@ def migrate_to_s3bucket_has_folder_path = true if ENV["DISCOURSE_S3_BUCKET"].include? "/"- s3 = Aws::S3::Client.new(+ opts = {region: ENV["DISCOURSE_S3_REGION"],access_key_id: ENV["DISCOURSE_S3_ACCESS_KEY_ID"],- secret_access_key: ENV["DISCOURSE_S3_SECRET_ACCESS_KEY"])+ secret_access_key: ENV["DISCOURSE_S3_SECRET_ACCESS_KEY"]+ }++ # S3::Client ignores the `region` option when an `endpoint` is provided.+ # Without `region`, non-default region bucket creation will break for S3, so we can only+ # define endpoint when not using S3 i.e. when SiteSetting.s3_endpoint is provided.+ opts[:endpoint] = SiteSetting.s3_endpoint if SiteSetting.s3_endpoint.present?+ s3 = Aws::S3::Client.new(opts)if bucket_has_folder_pathbucket, folder = S3Helper.get_bucket_and_folder_path(ENV["DISCOURSE_S3_BUCKET"])