Reviewed-on: https://git.openi.org.cn/OpenI/aiforge/pulls/1516 Reviewed-by: ychao_1983 <ychao_1983@sina.com>pull/1522/head
@@ -88,12 +88,25 @@ func (a *Attachment) APIFormat() *api.Attachment { | |||||
Size: a.Size, | Size: a.Size, | ||||
UUID: a.UUID, | UUID: a.UUID, | ||||
DownloadURL: a.DownloadURL(), | DownloadURL: a.DownloadURL(), | ||||
S3DownloadURL: a.S3DownloadURL(), | |||||
} | } | ||||
} | } | ||||
// DownloadURL returns the download url of the attached file | // DownloadURL returns the download url of the attached file | ||||
func (a *Attachment) DownloadURL() string { | 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 | // AttachmentRelativePath returns the relative path | ||||
@@ -16,9 +16,10 @@ type Attachment struct { | |||||
Size int64 `json:"size"` | Size int64 `json:"size"` | ||||
DownloadCount int64 `json:"download_count"` | DownloadCount int64 `json:"download_count"` | ||||
// swagger:strfmt date-time | // swagger:strfmt date-time | ||||
Created time.Time `json:"created_at"` | |||||
UUID string `json:"uuid"` | |||||
DownloadURL string `json:"browser_download_url"` | |||||
Created time.Time `json:"created_at"` | |||||
UUID string `json:"uuid"` | |||||
DownloadURL string `json:"browser_download_url"` | |||||
S3DownloadURL string | |||||
} | } | ||||
// EditAttachmentOptions options for editing attachments | // EditAttachmentOptions options for editing attachments | ||||
@@ -14,7 +14,7 @@ | |||||
<div class="eight wide column right aligned"> | <div class="eight wide column right aligned"> | ||||
<div class="ui left mini icon buttons"> | <div class="ui left mini icon buttons"> | ||||
<span class="ui basic button text left" data-tooltip='{{$.i18n.Tr "dataset.download_count"}}' data-position="bottom right" style="width: 60px; padding-left: 0;">{{svg "octicon-flame" 16}} {{(.DownloadCount | PrettyNumber)}}</span> | <span class="ui basic button text left" data-tooltip='{{$.i18n.Tr "dataset.download_count"}}' data-position="bottom right" style="width: 60px; padding-left: 0;">{{svg "octicon-flame" 16}} {{(.DownloadCount | PrettyNumber)}}</span> | ||||
<span class="ui basic basic button clipboard" data-clipboard-text="{{.DownloadURL}}" data-tooltip='{{$.i18n.Tr "dataset.copy_url"}}' data-clipboard-action="copy"{{if ne $.Type 0}} style="display:none;"{{end}}>{{svg "octicon-file" 16}}</span> | |||||
<span class="ui basic basic button clipboard" data-clipboard-text="{{.DownloadURL}}" data-tooltip='{{$.i18n.Tr "dataset.copy_url"}}' data-clipboard-action="copy">{{svg "octicon-file" 16}}</span> | |||||
<span class="ui basic basic button clipboard" data-clipboard-text="{{.FileChunk.Md5}}" data-tooltip='{{$.i18n.Tr "dataset.copy_md5"}}' data-clipboard-action="copy">{{svg "octicon-file-binary" 16}}</span> | <span class="ui basic basic button clipboard" data-clipboard-text="{{.FileChunk.Md5}}" data-tooltip='{{$.i18n.Tr "dataset.copy_md5"}}' data-clipboard-action="copy">{{svg "octicon-file-binary" 16}}</span> | ||||
</div> | </div> | ||||
{{if eq .DecompressState 1}} | {{if eq .DecompressState 1}} | ||||