From fe9a8f47ea30dbd9637c803563abd74bda46900a Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期一, 06 五月 2024 17:24:11 +0800
Subject: [PATCH] 每月1号执行
---
controllers/attachment.go | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/controllers/attachment.go b/controllers/attachment.go
index f4b1b11..3729024 100644
--- a/controllers/attachment.go
+++ b/controllers/attachment.go
@@ -36,6 +36,7 @@
var attachmentList []*models.Attachment
for _, fileHeader := range files {
ext := strings.ToLower(path.Ext(fileHeader.Filename))[1:]
+ fileParams := strings.Split(fileHeader.Filename, ".")
var fileType constvar.FileType
if value, ok := constvar.FileExtMap[ext]; ok {
fileType = value
@@ -57,7 +58,7 @@
buffer := new(bytes.Buffer)
_, _ = io.Copy(buffer, file)
fileBytes := buffer.Bytes()
- fileUrl, err := upload.UploadFileToSeaWeed(string(fileType), ext, fileBytes)
+ fileUrl, err := upload.UploadFileToSeaWeed(string(fileType), fileHeader.Filename, fileBytes)
if err != nil {
logx.Errorf("file upload err: %v", err)
util.ResponseFormat(c, code.RequestParamError, err.Error())
@@ -73,13 +74,13 @@
attachmentList = append(attachmentList, attachment)
if fileType == constvar.FileType_Picture {
- thumbnailBytes, err := image.CreateThumbnail(fileBytes, 0, 600, 800)
+ thumbnailBytes, err := image.CreateThumbnail(fileBytes, 60, 0, 0)
if err != nil {
logx.Errorf("file upload err: %v", err)
util.ResponseFormat(c, code.RequestParamError, "鐢熸垚缂╃暐鍥惧け璐ワ細"+err.Error())
return
}
- thumbnailUrl, err := upload.UploadFileToSeaWeed(string(constvar.FileType_Thumbnail), ext, thumbnailBytes)
+ thumbnailUrl, err := upload.UploadFileToSeaWeed(string(constvar.FileType_Thumbnail), fileParams[0]+"thumbnail."+ext, thumbnailBytes)
if err != nil {
logx.Errorf("file upload err: %v", err)
util.ResponseFormat(c, code.RequestParamError, err.Error())
--
Gitblit v1.8.0