修复ppt制作保存ppt问题

This commit is contained in:
junleea 2025-04-05 13:42:39 +08:00
parent dd89e6b92e
commit 61ff3b0547
1 changed files with 11 additions and 4 deletions

View File

@ -8,10 +8,12 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"github.com/google/uuid"
"io" "io"
"log" "log"
"net/http" "net/http"
"os" "os"
"path"
"strconv" "strconv"
"strings" "strings"
"time" "time"
@ -374,16 +376,21 @@ func SparkSavePPTFileToUser(fileUrl string) (string, string, error) {
//https://bjcdn.openstorage.cn/xinghuo-privatedata/zhiwen/2025-04-02/6ebfc0b2-824a-4acc-a030-01acce938dab/3209de1bca814ac48884e015277360fd.pptx //https://bjcdn.openstorage.cn/xinghuo-privatedata/zhiwen/2025-04-02/6ebfc0b2-824a-4acc-a030-01acce938dab/3209de1bca814ac48884e015277360fd.pptx
fileName := fileUrl[strings.LastIndex(fileUrl, "/")+1:] fileName := fileUrl[strings.LastIndex(fileUrl, "/")+1:]
//文件保存路径 //文件保存路径
path := service.GetFilePath(proto.FILE_BASE_DIR) path_ := service.GetFilePath(proto.FILE_BASE_DIR)
saveFile := path + "/" + fileName
//获取文件后缀
fileSuffix := path.Ext(fileName)
//生成文件名
fileStoreName := uuid.NewString() + fileSuffix
saveFile := path_ + "/" + fileStoreName
//下载文件 //下载文件
err := DownloadFile(fileUrl, saveFile) err := DownloadFile(fileUrl, saveFile)
if err != nil { if err != nil {
log.Println("Download file error:", err) log.Println("Download file error:", err)
return "", "", err return "", "", err
} }
log.Println("Download file success:", fileName) log.Println("Download file success:", fileStoreName)
return fileName, path, nil return fileStoreName, path_, nil
} }
func DownloadFile(url, filePath string) error { func DownloadFile(url, filePath string) error {