fix(storage) handle download filename
This commit is contained in:
parent
50713cdbd8
commit
b23b3ee550
@ -73,7 +73,7 @@ func (df *DocFolderWithChildren) ToTreeSchema() *schema.DocFolderWithChildren {
|
|||||||
|
|
||||||
type Doc struct {
|
type Doc struct {
|
||||||
Base
|
Base
|
||||||
Name string `gorm:"column:name;type:varchar;not null"` // 文件夹名称
|
Name string `gorm:"column:name;type:varchar;not null"` // 文件名称
|
||||||
IsDeletable bool `gorm:"column:is_deletable;type:boolean;not null;default:true"` // 是否允许被删除
|
IsDeletable bool `gorm:"column:is_deletable;type:boolean;not null;default:true"` // 是否允许被删除
|
||||||
IsEditable bool `gorm:"column:is_editable;type:boolean;not null;default:true"` // 是否允许编辑名称
|
IsEditable bool `gorm:"column:is_editable;type:boolean;not null;default:true"` // 是否允许编辑名称
|
||||||
FolderID string `gorm:"column:folder_id;type:varchar;index:idx_folder_id"` // 文件夹ID
|
FolderID string `gorm:"column:folder_id;type:varchar;index:idx_folder_id"` // 文件夹ID
|
||||||
@ -98,7 +98,7 @@ func (d *Doc) ToSchema(ctx context.Context) *schema.Doc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *Doc) PresignedURL(ctx context.Context) (*url.URL, error) {
|
func (d *Doc) PresignedURL(ctx context.Context) (*url.URL, error) {
|
||||||
return dal.GetStorage().PresignedGetObject(ctx, d.ObjectName, time.Hour)
|
return dal.GetStorage().PresignedGetObject(ctx, d.ObjectName, time.Hour, d.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*Doc) TableName() string {
|
func (*Doc) TableName() string {
|
||||||
|
@ -45,8 +45,11 @@ func (m *Storage) PresignedPutObject(ctx context.Context, objectName string, exp
|
|||||||
}
|
}
|
||||||
|
|
||||||
// PresignedGetObject implements ObjectStorage
|
// PresignedGetObject implements ObjectStorage
|
||||||
func (m *Storage) PresignedGetObject(ctx context.Context, objectName string, expires time.Duration) (u *url.URL, err error) {
|
func (m *Storage) PresignedGetObject(ctx context.Context, objectName string, expires time.Duration, fileName string) (u *url.URL, err error) {
|
||||||
return m.client.PresignedGetObject(ctx, m.bucket, objectName, expires, nil)
|
p := url.Values{
|
||||||
|
"response-content-disposition": []string{"attachment; filename*=utf-8''" + url.QueryEscape("真的吗.txt")},
|
||||||
|
}
|
||||||
|
return m.client.PresignedGetObject(ctx, m.bucket, objectName, expires, p)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MoveObject implements ObjectStorage
|
// MoveObject implements ObjectStorage
|
||||||
|
Loading…
x
Reference in New Issue
Block a user