mirror of
https://github.com/discourse/discourse.git
synced 2025-06-01 02:04:53 +08:00
DEV: allow using CDN URL for all s3 uploads (#20755)
This adds an option to allow non-image s3 files to be downloaded through CDN URL. Addresses the issues in: * meta.discourse.org/t/s3-cdn-url-not-being-used-on-non-image-uploads/175332 * meta.discourse.org/t/s3-uploads-using-cdn-for-pdfs/213218
This commit is contained in:
@ -375,6 +375,18 @@ RSpec.describe UploadCreator do
|
||||
expect(stored_upload.url).not_to eq(signed_url)
|
||||
expect(signed_url).to match(/Amz-Credential/)
|
||||
end
|
||||
|
||||
it "should return CDN URL when enabled" do
|
||||
SiteSetting.s3_use_cdn_url_for_all_uploads = true
|
||||
SiteSetting.authorized_extensions = "pdf"
|
||||
SiteSetting.s3_cdn_url = "https://example-cdn.com"
|
||||
|
||||
upload = UploadCreator.new(pdf_file, pdf_filename, opts).create_for(user.id)
|
||||
stored_upload = Upload.last
|
||||
cdn_url = Discourse.store.url_for(stored_upload)
|
||||
|
||||
expect(cdn_url).to match(/example-cdn\.com/)
|
||||
end
|
||||
end
|
||||
|
||||
context "when the upload already exists based on the sha1" do
|
||||
|
Reference in New Issue
Block a user