Commit 7e0d4cd0 by CaIon

refactor: move maxFileSize variable inside GetFileBase64FromUrl function

parent 95f0ed18
...@@ -8,9 +8,9 @@ import ( ...@@ -8,9 +8,9 @@ import (
"one-api/dto" "one-api/dto"
) )
var maxFileSize = constant.MaxFileDownloadMB * 1024 * 1024
func GetFileBase64FromUrl(url string) (*dto.LocalFileData, error) { func GetFileBase64FromUrl(url string) (*dto.LocalFileData, error) {
var maxFileSize = constant.MaxFileDownloadMB * 1024 * 1024
resp, err := DoDownloadRequest(url) resp, err := DoDownloadRequest(url)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -22,7 +22,6 @@ func GetFileBase64FromUrl(url string) (*dto.LocalFileData, error) { ...@@ -22,7 +22,6 @@ func GetFileBase64FromUrl(url string) (*dto.LocalFileData, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
// Check actual size after reading // Check actual size after reading
if len(fileBytes) > maxFileSize { if len(fileBytes) > maxFileSize {
return nil, fmt.Errorf("file size exceeds maximum allowed size: %dMB", constant.MaxFileDownloadMB) return nil, fmt.Errorf("file size exceeds maximum allowed size: %dMB", constant.MaxFileDownloadMB)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment