Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
7e0d4cd0
authored
Apr 11, 2025
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: move maxFileSize variable inside GetFileBase64FromUrl function
parent
95f0ed18
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
3 deletions
+2
-3
service/file_decoder.go
+2
-3
No files found.
service/file_decoder.go
View file @
7e0d4cd0
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment