mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Use s3_endpoint in migrate_to_s3 when not using S3
- overrides :region and uses :endpoint when SiteSetting.s3_endpoint is provided
- Now, we can use the new rake task with DigitalOcean Spaces
- I've tested that it's compatible with/without bucket folder path
- I've tested that it's compatible with S3 and it doesn't break S3 for non-default regions
- follow-up on 97e17fe0
This commit is contained in:
parent
72d14a11ab
commit
e69634ec3a
@ -246,10 +246,17 @@ def migrate_to_s3
|
|||||||
|
|
||||||
bucket_has_folder_path = true if ENV["DISCOURSE_S3_BUCKET"].include? "/"
|
bucket_has_folder_path = true if ENV["DISCOURSE_S3_BUCKET"].include? "/"
|
||||||
|
|
||||||
s3 = Aws::S3::Client.new(
|
opts = {
|
||||||
region: ENV["DISCOURSE_S3_REGION"],
|
region: ENV["DISCOURSE_S3_REGION"],
|
||||||
access_key_id: ENV["DISCOURSE_S3_ACCESS_KEY_ID"],
|
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_path
|
if bucket_has_folder_path
|
||||||
bucket, folder = S3Helper.get_bucket_and_folder_path(ENV["DISCOURSE_S3_BUCKET"])
|
bucket, folder = S3Helper.get_bucket_and_folder_path(ENV["DISCOURSE_S3_BUCKET"])
|
||||||
|
Loading…
Reference in New Issue
Block a user