Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
X
xxx_phase2_web
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
夏敏伟
xxx_phase2_web
Commits
fcebe14c
Commit
fcebe14c
authored
Nov 30, 2023
by
以墨为白
🎧
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
大文件增加请求头
parent
a9b3ffeb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
6 deletions
+16
-6
src/components/common/bigfileUpload.vue
src/components/common/bigfileUpload.vue
+16
-6
No files found.
src/components/common/bigfileUpload.vue
View file @
fcebe14c
...
...
@@ -21,6 +21,7 @@
import
$
from
"
jquery
"
;
import
WebUploader
from
"
webuploader
"
;
import
"
webuploader/dist/webuploader.css
"
;
import
{
ACCESS_TOKEN
,
ACCESS_USER
,
HTTP_STATUS
}
from
"
../../constant/user
"
;
export
default
{
props
:
[
'
fileType
'
],
data
()
{
...
...
@@ -29,6 +30,10 @@ export default {
};
},
mounted
()
{
let
headers_target
=
{
'
x-requested-with
'
:
'
XMLHttpRequest
'
};
headers_target
[
ACCESS_TOKEN
]
=
sessionStorage
.
getItem
(
"
token
"
);
var
_self
=
this
;
//必须先注销原来的,否则服务会执行多次
WebUploader
.
Uploader
.
unRegister
(
"
uploadBigFile
"
);
...
...
@@ -62,6 +67,7 @@ export default {
type
:
"
POST
"
,
url
:
"
api/rest/file/bigFile/check
"
,
async
:
false
,
headers
:
headers_target
,
data
:
{
fileMd5
:
val
,
},
...
...
@@ -125,6 +131,7 @@ export default {
$
.
ajax
({
type
:
"
POST
"
,
url
:
"
api/rest/file/bigFile/merge
"
,
headers
:
headers_target
,
data
:
{
fileName
:
file
.
name
,
fileMd5
:
file
.
md5
,
...
...
@@ -172,11 +179,13 @@ export default {
/**
* 当某个文件的分块在发送前触发,主要用来询问是否要添加附带参数,大文件在开起分片上传的前提下此事件可能会触发多次。
*/
uploader
.
onUploadBeforeSend
=
function
(
obj
,
data
)
{
//
console.log("onUploadBeforeSend");
uploader
.
onUploadBeforeSend
=
function
(
obj
,
data
,
headers
)
{
//
增加请求参数
var
file
=
obj
.
file
;
data
.
md5
=
file
.
md5
||
""
;
data
.
uid
=
file
.
uid
;
//增加请求token
$
.
extend
(
headers
,
headers_target
);
};
/**
* 上传过程中,一直会执行该方法
...
...
@@ -252,18 +261,19 @@ export default {
list-style
:
none
;
margin
:
10px
0px
;
.el-progress
{
.el-progress
{
width
:
95%
;
margin-top
:
3px
;
.el-progress-bar
{
.el-progress-bar__outer
{
.el-progress-bar
{
.el-progress-bar__outer
{
height
:
12px
!
important
;
}
}
}
}
.startUpload
{
.startUpload
{
margin-top
:
5px
;
}
</
style
>
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