forked from Trustie/forgeplus
FIX 附件文件兼容oss地址
This commit is contained in:
parent
9085246b4a
commit
4c51feae24
|
|
@ -196,17 +196,7 @@ class Attachment < ApplicationRecord
|
|||
end
|
||||
|
||||
def get_cloud_url(disposition="attachment")
|
||||
if (self.container_type == "Shixun" && [11, 12, 13].include?(self.attachtype)) ||
|
||||
((["VirtualClassroomGoodLesson", "VirtualClassroomDiscussion", "Course"].include?(self.container_type)) && self.attachtype == 11) ||
|
||||
(self.container_type == "VirtualClassroomGoodLesson" && self.attachtype == 30) ||
|
||||
(self.container_type == "VirtualClassroomDiscussion" && self.attachtype == 31)
|
||||
cloud_url = self.oss_absolute_url
|
||||
elsif self.digest.start_with?(SLUG_PREFIX)
|
||||
bucket = %w[SmartPlan].include?(self.container_type) ? OSS.client.get_bucket(OSS.bucket_big_files) : OSS.client.get_bucket(OSS.attachments_oss_bucket)
|
||||
cloud_url = bucket.object_url(self.cloud_url, true, 10 * 3600 * 24, {"response-content-disposition": "attachment;\"filename=#{URI.encode(self.filename.strip)}\";attachment_id=#{self.id}"})
|
||||
elsif ["Stage", "Course"].include?(self.container_type) && OSS.client.get_bucket(OSS.bucket_big_files).object_exists?(self.cloud_url)
|
||||
cloud_url = ApplicationController.helpers.cdn_a_auth_url(self)
|
||||
elsif self.cloud_url.include?("http")
|
||||
if self.cloud_url.include?("http")
|
||||
cloud_url = self.cloud_url
|
||||
else
|
||||
bucket = OSS.client.get_bucket(OSS.attachments_oss_bucket)
|
||||
|
|
|
|||
Loading…
Reference in New Issue