feat(storage): add cos support

This commit is contained in:
neo-f
2023-03-23 13:52:44 +08:00
parent 05c133a4b5
commit a56f0b8150
13 changed files with 283 additions and 90 deletions

View File

@@ -3,7 +3,6 @@ package model
import (
"context"
"net/url"
"octopus/internal/config"
"octopus/internal/dal"
"time"
@@ -37,15 +36,14 @@ type Doc struct {
IsDeletable bool `gorm:"column:is_deletable;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
OSSObjectID string `gorm:"column:oss_object_id;type:varchar"` // OSS Object ID
ObjectName string `gorm:"column:object_name;type:varchar"` // 对象存储中对应的object_name
CreatedBy string `gorm:"column:created_by;type:varchar;not null"` // 创建人
Folder *DocFolder `gorm:"foreignKey:FolderID;references:ID"`
}
func (df *Doc) PresignedURL(ctx context.Context) (*url.URL, error) {
bucket := config.Get().GetOSSConfig().Bucket
return dal.GetMinio().PresignedGetObject(ctx, bucket, df.OSSObjectID, time.Hour, nil)
return dal.GetStorage().PresignedGetObject(ctx, df.ObjectName, time.Hour)
}
func (*Doc) TableName() string {