Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
VueElementTemplate
Project
Project
Details
Activity
Releases
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄瑜
VueElementTemplate
Commits
46b6a6e1
Commit
46b6a6e1
authored
Jun 02, 2017
by
Pan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add qiniu upload example
parent
e8fb41d0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
27 deletions
+51
-27
qiniu.js
src/api/qiniu.js
+7
-27
upload.vue
src/views/qiniu/upload.vue
+44
-0
No files found.
src/api/qiniu.js
View file @
46b6a6e1
// import fetch, { tpFetch }
from 'utils/fetch';
import
fetch
from
'utils/fetch'
;
// export function getToken() {
export
function
getToken
()
{
// return fetch({
return
fetch
({
// url: '/qiniu/upload/token',
url
:
'/qiniu/upload/token'
,
// 假地址 自行替换
// method: 'get'
method
:
'get'
// });
});
// }
}
// export function upload(data) {
// return tpFetch({
// url: 'https://upload.qbox.me',
// method: 'post',
// data
// });
// }
// /* 外部uri转七牛uri*/
// export function netUpload(token, net_url) {
// const imgData = {
// net_url
// };
// return fetch({
// url: '/qiniu/upload/net/async',
// method: 'post',
// data: imgData
// });
// }
src/views/qiniu/upload.vue
0 → 100644
View file @
46b6a6e1
<
template
>
<el-upload
action=
"https://upload.qbox.me"
:data=
"dataObj"
drag
:multiple=
"true"
:before-upload=
"beforeUpload"
>
<i
class=
"el-icon-upload"
></i>
<div
class=
"el-upload__text"
>
将文件拖到此处,或
<em>
点击上传
</em></div>
</el-upload>
</
template
>
<
script
>
import
{
getToken
}
from
'api/qiniu'
;
// 获取七牛token 后端通过Access Key,Secret Key,bucket等生成token
// 七牛官方sdk https://developer.qiniu.com/sdk#official-sdk
export
default
{
data
()
{
return
{
dataObj
:
{
token
:
''
,
key
:
''
},
image_uri
:
[],
fileList
:
[]
}
},
methods
:
{
beforeUpload
()
{
const
_self
=
this
;
return
new
Promise
((
resolve
,
reject
)
=>
{
getToken
().
then
(
response
=>
{
const
key
=
response
.
data
.
qiniu_key
;
const
token
=
response
.
data
.
qiniu_token
;
_self
.
_data
.
dataObj
.
token
=
token
;
_self
.
_data
.
dataObj
.
key
=
key
;
resolve
(
true
);
}).
catch
(
err
=>
{
console
.
log
(
err
)
reject
(
false
)
});
});
}
}
}
</
script
>
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