Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
traceSourceMb
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
yanyanhong
traceSourceMb
Commits
7b829400
Commit
7b829400
authored
Jan 15, 2021
by
yyh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor:提取获取文件后缀函数
parent
0f58441a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
3 deletions
+6
-3
file.ts
src/api/modules/file.ts
+6
-3
No files found.
src/api/modules/file.ts
View file @
7b829400
import
axios
from
'@/utils/http'
;
const
base
=
process
.
env
.
VUE_APP_SERVER
+
'/file'
;
function
getFileSuffix
(
file
:
File
)
{
const
fileName
=
file
.
name
;
const
index
=
fileName
.
lastIndexOf
(
'.'
);
return
fileName
.
substr
(
index
+
1
);
}
export
default
{
upload
(
file
:
File
,
cb
:
(
progressEvent
:
any
)
=>
void
=
(
progressEvent
:
any
)
=>
progressEvent
)
{
const
suffix
=
getFileSuffix
(
file
);
const
formData
=
new
FormData
();
const
filename
=
file
.
name
;
const
index
=
filename
.
lastIndexOf
(
'.'
);
const
suffix
=
filename
.
substr
(
index
+
1
);
formData
.
append
(
'file_data'
,
file
);
return
axios
({
url
:
`
${
base
}
/upload?file_type=
${
suffix
}
`
,
...
...
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