FIX 附件文件兼容oss地址

This commit is contained in:
jasder duan 2026-03-31 15:41:35 +08:00
parent 9085246b4a
commit 4c51feae24
1 changed files with 1 additions and 11 deletions

View File

@ -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)