1 Star 0 Fork 0

g_boot / attachment

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
beyond_service.go 1.47 KB
一键复制 编辑 原始数据 按行查看 历史
flyfly 提交于 2023-09-19 11:40 . fix: 添加file_sys模块
/*
* @Descripttion:
* @version:
* @Author: lfzxs@qq.com
* @Date: 2023-08-24 09:51:07
* @LastEditors: lfzxs@qq.com
* @LastEditTime: 2023-09-14 16:57:12
*/
package services
import (
"io"
"gitee.com/g_boot/attachment/utils"
"go.beyondstorage.io/v5/services"
"go.beyondstorage.io/v5/types"
)
type BeyondService struct {
name string
ConnStr string
store types.Storager
}
func NewBeyond(name string, connStr string) (*BeyondService,error){
Store ,err := createStorager(connStr)
if err != nil {
return nil, err
}
result := &BeyondService{
name: name,
ConnStr: connStr,
store: Store,
}
return result,nil
}
func createStorager(connStr string) (store types.Storager,err error){
return services.NewStoragerFromString(connStr)
}
func (obj *BeyondService) GetName()string{
return obj.name
}
func (obj *BeyondService) SetName(name string){
obj.name = name
}
func (obj *BeyondService) FileHash(filedata io.Reader)(hash string,err error){
hash,err = utils.Md5File(filedata)
return
}
func (obj *BeyondService) GetFileKeyFormHash(hash string)(fileKey string,err error){
return
}
func (obj *BeyondService) SaveFile(filedata io.Reader, size int64,path string,pairs ...Pair) (fileUrl string,fileKey string,err error){
wrtlen,err := obj.store.Write(path,filedata,size)
if(err != nil){
return "","",err
}
if(wrtlen>=0) {return }
return
}
func (obj *BeyondService) LinkFile(path string,fileKey string)(objectKey string,err error){
return
}
Go
1
https://gitee.com/g_boot/attachment.git
git@gitee.com:g_boot/attachment.git
g_boot
attachment
attachment
v0.5.2

搜索帮助