From 318c49da20ec30c4f85ef35e479499e82a841b25 Mon Sep 17 00:00:00 2001
From: liujiandao <274878379@qq.com>
Date: 星期一, 11 三月 2024 14:18:13 +0800
Subject: [PATCH] swag提交

---
 utils/upload/seaweed.go |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/utils/upload/seaweed.go b/utils/upload/seaweed.go
index acc30e6..0efd120 100644
--- a/utils/upload/seaweed.go
+++ b/utils/upload/seaweed.go
@@ -1 +1,23 @@
 package upload
+
+import (
+	"basic.com/fileserver/WeedFSClient.git"
+	"time"
+	"wms/conf"
+	"wms/pkg/logx"
+)
+
+func UploadFileToSeaWeed(fileType, fileName string, fileBytes []byte) (string, error) {
+	//assignUrl := conf.WebConf.FileServer + "/dir/assign?collection=" + time.Now().Format("2006-01-02 15:04:05")[:10] + "-" + conf.WebConf.ServerId + "-" + fileType
+	assignUrl := conf.WebConf.FileServer + "/dir/assign?collection=12345-" + conf.WebConf.ServerId + "-" + fileType
+
+	picUrl, err := WeedFSClient.GetFid(assignUrl)
+	if err != nil {
+		logx.Error(err.Error())
+		return picUrl, err
+	}
+
+	//picFileName := uuid.NewV4().String() + "." + ext
+	go WeedFSClient.UploadFile(picUrl, fileName, fileBytes, 3*time.Second)
+	return picUrl, nil
+}

--
Gitblit v1.8.0