You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# lib/active_storage_blob_extension.rb
module ActiveStorageBlobExtension
extend ActiveSupport::Concern
included do
def cdn_service_url
if ENV['CDN_HOST'].present?
"#{ENV['CDN_HOST']}/#{self.key}"
else
self.service_url
end
end
end
end
# config/application.rb
...
config.to_prepare do
ActiveStorage::Blob.send :include, ::ActiveStorageBlobExtension
end
...
The text was updated successfully, but these errors were encountered:
背景是这样的,我在使用阿里云的OSS,机器的带宽有限,每次上传都是走公网的endpoint,如果上传大图就跪了。所以我希望上传的时候可以用内网的endpoint,然后获取service_url的时候是拿公网的host。
我目前使用的Rails版本是6.0
目前我的解决方案是这样的,个人感觉不是特别好。
The text was updated successfully, but these errors were encountered: