FIX: Videos and audio files were not associated to the post.

This commit is contained in:
Guo Xiang Tan
2016-10-18 15:58:45 +08:00
parent 2a9331d061
commit 7db33cc512
4 changed files with 71 additions and 17 deletions

View File

@@ -230,6 +230,12 @@ class Upload < ActiveRecord::Base
url = url.sub(Discourse.asset_host, "") if Discourse.asset_host.present?
# when using s3, we need to replace with the absolute base url
url = url.sub(SiteSetting.s3_cdn_url, Discourse.store.absolute_base_url) if SiteSetting.s3_cdn_url.present?
# always try to get the path
if (uri = URI(url)).scheme
url = uri.path
end
Upload.find_by(url: url)
end