feat:pdf上传完之后就删除
This commit is contained in:
parent
dfb2e5e037
commit
bdf3fa6144
@ -15,6 +15,7 @@ import (
|
||||
"fonchain-fiee/pkg/service"
|
||||
"fonchain-fiee/pkg/service/upload"
|
||||
"fonchain-fiee/pkg/utils"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"time"
|
||||
@ -101,6 +102,18 @@ func CreateCompetitiveReport(ctx *gin.Context) {
|
||||
}
|
||||
fmt.Println("生成PDF成功", pdfFilePath)
|
||||
|
||||
// 确保在上传后(无论成功或失败)删除临时PDF文件
|
||||
defer func() {
|
||||
// 检查文件是否存在,存在才删除
|
||||
if _, err := os.Stat(pdfFilePath); err == nil {
|
||||
if err := os.Remove(pdfFilePath); err != nil {
|
||||
zap.L().Warn("删除临时PDF文件失败", zap.String("path", pdfFilePath), zap.Error(err))
|
||||
} else {
|
||||
zap.L().Info("删除临时PDF文件成功", zap.String("path", pdfFilePath))
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
// 上传PDF到OSS
|
||||
pdfUrl, uploadErr := upload.PutBos(pdfFilePath, upload.PdfType, true)
|
||||
if uploadErr != nil {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user