|
|
@@ -88,6 +88,7 @@ func (a *Attachment) APIFormat() *api.Attachment { |
|
|
|
Size: a.Size, |
|
|
|
UUID: a.UUID, |
|
|
|
DownloadURL: a.DownloadURL(), |
|
|
|
S3DownloadURL: a.S3DownloadURL(), |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@@ -96,6 +97,18 @@ func (a *Attachment) DownloadURL() string { |
|
|
|
return fmt.Sprintf("%sattachments/%s", setting.AppURL, a.UUID) |
|
|
|
} |
|
|
|
|
|
|
|
// DownloadURL returns the 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 { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return url |
|
|
|
} |
|
|
|
|
|
|
|
// AttachmentRelativePath returns the relative path |
|
|
|
func AttachmentRelativePath(uuid string) string { |
|
|
|
return path.Join(uuid[0:1], uuid[1:2], uuid) |
|
|
|