Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
admin
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
ff14cf90
authored
Apr 30, 2024
by
khalidlife
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(useUpload.ts): 修复前端文件上传Content-Type异常问题
parent
6f38676a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
1 deletions
+5
-1
src/components/UploadFile/src/useUpload.ts
+5
-1
No files found.
src/components/UploadFile/src/useUpload.ts
View file @
ff14cf90
...
...
@@ -17,7 +17,11 @@ export const useUpload = () => {
// 1.2 获取文件预签名地址
const
presignedInfo
=
await
FileApi
.
getFilePresignedUrl
(
fileName
)
// 1.3 上传文件(不能使用 ElUpload 的 ajaxUpload 方法的原因:其使用的是 FormData 上传,Minio 不支持)
return
axios
.
put
(
presignedInfo
.
uploadUrl
,
options
.
file
).
then
(()
=>
{
return
axios
.
put
(
presignedInfo
.
uploadUrl
,
options
.
file
,
{
headers
:
{
'Content-Type'
:
options
.
file
.
type
,
}
}).
then
(()
=>
{
// 1.4. 记录文件信息到后端(异步)
createFile
(
presignedInfo
,
fileName
,
options
.
file
)
// 通知成功,数据格式保持与后端上传的返回结果一致
...
...
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