|
|
@@ -88,12 +88,25 @@ func (a *Attachment) APIFormat() *api.Attachment { |
|
|
|
Size: a.Size, |
|
|
|
UUID: a.UUID, |
|
|
|
DownloadURL: a.DownloadURL(), |
|
|
|
S3DownloadURL: a.S3DownloadURL(), |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// DownloadURL returns the download url of the attached file |
|
|
|
func (a *Attachment) DownloadURL() string { |
|
|
|
return fmt.Sprintf("%sattachments/%s", setting.AppURL, a.UUID) |
|
|
|
return fmt.Sprintf("%sattachments/%s?type=%d", setting.AppURL, a.UUID, a.Type) |
|
|
|
} |
|
|
|
|
|
|
|
// S3DownloadURL returns the s3 download url of the attached file |
|
|
|
func (a *Attachment) S3DownloadURL() string { |
|
|
|
url := "" |
|
|
|
if a.Type == TypeCloudBrainOne { |
|
|
|
url, _ = storage.Attachments.PresignedGetURL(setting.Attachment.Minio.BasePath+AttachmentRelativePath(a.UUID), a.Name) |
|
|
|
} else if a.Type == TypeCloudBrainTwo { |
|
|
|
url, _ = storage.ObsGetPreSignedUrl(a.UUID, a.Name) |
|
|
|
} |
|
|
|
|
|
|
|
return url |
|
|
|
} |
|
|
|
|
|
|
|
// AttachmentRelativePath returns the relative path |
|
|
|