Documentation
¶
Overview ¶
Package objdao 对象存储DAO
Index ¶
- type CosObjDAO
- func (dao *CosObjDAO) CheckObjectExists(ctx context.Context, userID uint, objectName string) (exists bool, err error)
- func (dao *CosObjDAO) CreateBucket(ctx context.Context) (err error)
- func (dao *CosObjDAO) CreateDir(ctx context.Context, userID uint) (objectInfo *ObjectInfo, err error)
- func (dao *CosObjDAO) DeleteObject(ctx context.Context, userID uint, objectName string) (err error)
- func (dao *CosObjDAO) DownloadObject(ctx context.Context, userID uint, objectName string, writer io.Writer) (objectInfo *ObjectInfo, err error)
- func (dao *CosObjDAO) GetBucketName(_ context.Context) string
- func (dao *CosObjDAO) ListObjects(ctx context.Context, userID uint) (objectInfos []ObjectInfo, err error)
- func (dao *CosObjDAO) PresignObject(ctx context.Context, userID uint, objectName string) (presignedURL *url.URL, err error)
- func (dao *CosObjDAO) UploadObject(ctx context.Context, userID uint, objectName string, _ int64, reader io.Reader) (err error)
- type MinioObjDAO
- func (dao *MinioObjDAO) CheckObjectExists(ctx context.Context, userID uint, objectName string) (exists bool, err error)
- func (dao *MinioObjDAO) CreateBucket(ctx context.Context) (err error)
- func (dao *MinioObjDAO) CreateDir(ctx context.Context, userID uint) (objectInfo *ObjectInfo, err error)
- func (dao *MinioObjDAO) DeleteObject(ctx context.Context, userID uint, objectName string) (err error)
- func (dao *MinioObjDAO) DownloadObject(ctx context.Context, userID uint, objectName string, writer io.Writer) (objectInfo *ObjectInfo, err error)
- func (dao *MinioObjDAO) GetBucketName(_ context.Context) string
- func (dao *MinioObjDAO) ListObjects(ctx context.Context, userID uint) (objectInfos []ObjectInfo, err error)
- func (dao *MinioObjDAO) PresignObject(ctx context.Context, userID uint, objectName string) (presignedURL *url.URL, err error)
- func (dao *MinioObjDAO) UploadObject(ctx context.Context, userID uint, objectName string, size int64, ...) (err error)
- type ObjDAO
- type ObjectInfo
- type ObjectType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CosObjDAO ¶
type CosObjDAO struct {
ObjectType ObjectType
BucketName string
// contains filtered or unexported fields
}
CosObjDAO 腾讯云COS对象存储DAO
author centonhuang update 2025-01-19 14:13:22
func (*CosObjDAO) CheckObjectExists ¶
func (dao *CosObjDAO) CheckObjectExists(ctx context.Context, userID uint, objectName string) (exists bool, err error)
CheckObjectExists 检查对象是否存在
@receiver dao *CosObjDAO @param ctx context.Context @param userID uint @param objectName string @return exists bool @return err error @author centonhuang @update 2025-11-02 06:05:27
func (*CosObjDAO) CreateBucket ¶
CreateBucket 创建桶
func (*CosObjDAO) CreateDir ¶
func (dao *CosObjDAO) CreateDir(ctx context.Context, userID uint) (objectInfo *ObjectInfo, err error)
CreateDir 创建目录
func (*CosObjDAO) DeleteObject ¶
DeleteObject 删除对象
func (*CosObjDAO) DownloadObject ¶
func (dao *CosObjDAO) DownloadObject(ctx context.Context, userID uint, objectName string, writer io.Writer) (objectInfo *ObjectInfo, err error)
DownloadObject 下载对象
func (*CosObjDAO) GetBucketName ¶
GetBucketName 获取桶名
receiver dao *CosObjDAO return bucketName string author centonhuang update 2025-01-19 14:13:22
func (*CosObjDAO) ListObjects ¶
func (dao *CosObjDAO) ListObjects(ctx context.Context, userID uint) (objectInfos []ObjectInfo, err error)
ListObjects 列出桶中的对象
type MinioObjDAO ¶
type MinioObjDAO struct {
ObjectType ObjectType
BucketName string
// contains filtered or unexported fields
}
MinioObjDAO 基础Minio对象存储DAO
author centonhuang update 2025-01-05 22:45:43
func (*MinioObjDAO) CheckObjectExists ¶
func (dao *MinioObjDAO) CheckObjectExists(ctx context.Context, userID uint, objectName string) (exists bool, err error)
CheckObjectExists 检查对象是否存在
receiver dao *BaseMinioObjDAO param userID uint param objectName string return exists bool return err error author centonhuang update 2025-11-02 05:36:10
func (*MinioObjDAO) CreateBucket ¶
func (dao *MinioObjDAO) CreateBucket(ctx context.Context) (err error)
CreateBucket 创建桶
receiver dao *BaseMinioObjDAO param userID uint return exist bool return err error author centonhuang update 2025-01-05 17:37:41
func (*MinioObjDAO) CreateDir ¶
func (dao *MinioObjDAO) CreateDir(ctx context.Context, userID uint) (objectInfo *ObjectInfo, err error)
CreateDir 创建目录
receiver dao *BaseMinioObjDAO param userID uint return objectInfo *ObjectInfo return err error author centonhuang update 2025-01-18 17:37:41
func (*MinioObjDAO) DeleteObject ¶
func (dao *MinioObjDAO) DeleteObject(ctx context.Context, userID uint, objectName string) (err error)
DeleteObject 删除对象
receiver dao *BaseMinioObjDAO param userID uint param objectName string return err error author centonhuang update 2025-01-05 17:38:09
func (*MinioObjDAO) DownloadObject ¶
func (dao *MinioObjDAO) DownloadObject(ctx context.Context, userID uint, objectName string, writer io.Writer) (objectInfo *ObjectInfo, err error)
DownloadObject 下载对象
receiver dao *BaseMinioObjDAO param userID uint param objectName string param writer io.Writer return objectInfo *ObjectInfo return err error author centonhuang update 2025-01-05 17:37:57
func (*MinioObjDAO) GetBucketName ¶
func (dao *MinioObjDAO) GetBucketName(_ context.Context) string
GetBucketName 获取桶名
receiver dao *BaseMinioObjDAO return bucketName string author centonhuang update 2025-01-19 14:13:22
func (*MinioObjDAO) ListObjects ¶
func (dao *MinioObjDAO) ListObjects(ctx context.Context, userID uint) (objectInfos []ObjectInfo, err error)
ListObjects 列出桶中的对象
receiver dao *BaseMinioObjDAO param userID uint return objectInfos []ObjectInfo return err error author centonhuang update 2025-01-05 17:37:45
func (*MinioObjDAO) PresignObject ¶
func (dao *MinioObjDAO) PresignObject(ctx context.Context, userID uint, objectName string) (presignedURL *url.URL, err error)
PresignObject 生成对象的预签名URL
receiver dao *BaseMinioObjDAO param userID uint param objectName string param writer io.Writer return url *url.URL return err error author centonhuang update 2025-01-05 17:38:03
func (*MinioObjDAO) UploadObject ¶
func (dao *MinioObjDAO) UploadObject(ctx context.Context, userID uint, objectName string, size int64, reader io.Reader) (err error)
UploadObject 上传对象
receiver dao *BaseMinioObjDAO param userID uint param objectName string param size int64 param reader io.Reader return err error author centonhuang update 2025-01-05 17:37:50
type ObjDAO ¶
type ObjDAO interface {
GetBucketName(ctx context.Context) string
CreateBucket(ctx context.Context) (err error)
CreateDir(ctx context.Context, userID uint) (objectInfo *ObjectInfo, err error)
ListObjects(ctx context.Context, userID uint) (objectInfos []ObjectInfo, err error)
CheckObjectExists(ctx context.Context, userID uint, objectName string) (exists bool, err error)
UploadObject(ctx context.Context, userID uint, objectName string, size int64, reader io.Reader) (err error)
DownloadObject(ctx context.Context, userID uint, objectName string, writer io.Writer) (objectInfo *ObjectInfo, err error)
PresignObject(ctx context.Context, userID uint, objectName string) (presignedURL *url.URL, err error)
DeleteObject(ctx context.Context, userID uint, objectName string) (err error)
}
ObjDAO 对象存储DAO接口
author centonhuang update 2025-01-05 22:45:30
func GetImageObjDAO ¶
func GetImageObjDAO() ObjDAO
GetImageObjDAO 获取图片对象DAO单例
return ObjDAO author centonhuang update 2024-10-18 01:10:28
func GetThumbnailObjDAO ¶
func GetThumbnailObjDAO() ObjDAO
GetThumbnailObjDAO 获取缩略图对象DAO单例
return ObjDAO author centonhuang update 2024-10-18 01:09:59
type ObjectInfo ¶
type ObjectInfo struct {
ObjectName string `json:"objectName"`
ContentType string `json:"contentType"`
Size int64 `json:"size"`
LastModified time.Time `json:"lastModified"`
Expires time.Time `json:"expires"`
ETag string `json:"etag"`
}
ObjectInfo 对象信息
author centonhuang update 2025-01-05 22:45:48
type ObjectType ¶
type ObjectType string
ObjectType 对象类型
author centonhuang update 2025-01-05 22:45:37
const ( // ObjectTypeImage ObjectType // update 2025-01-05 17:36:01 ObjectTypeImage ObjectType = "image" // ObjectTypeThumbnail ObjectType // update 2025-01-05 17:36:05 ObjectTypeThumbnail ObjectType = "thumbnail" )
Click to show internal directories.
Click to hide internal directories.