-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
2,028 additions
and
1,943 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import React from 'react' | ||
import PropTypes from "prop-types"; | ||
import * as qiniu from 'qiniu-js' | ||
import Style from './index.scss' | ||
import { notification } from 'antd'; | ||
|
||
class Upload extends React.Component{ | ||
|
||
|
||
uploadFn = () => { | ||
let files = this.refs.upload.files | ||
let fileType = files[0].type; | ||
if (/^image/.test(fileType)) { | ||
// 读取结果在fileReader.result里面 | ||
|
||
} else { | ||
notification['error']({ | ||
message: "请选择图片类型文件" | ||
}) | ||
} | ||
|
||
var putExtra = { | ||
fname: "", | ||
params: {}, | ||
mimeType: [] || null | ||
}; | ||
var config = { | ||
// useCdnDomain: true, | ||
region: qiniu.region.z2 | ||
}; | ||
let token = 'Jyi6Ntprm38nI6n1heGjwXyQmzie8ZjY7l9Cq_Je:pmA4lE0xsPRmnGO9s8cEkgTGJ-g=:eyJzY29wZSI6ImRhbmthbC1jZG4iLCJkZWFkbGluZSI6MTU0MzI1Mjk3M30=' | ||
var observable = qiniu.upload(files[0], null, token, putExtra, config) | ||
|
||
var observer = { | ||
next(res){ | ||
console.log(res) | ||
// ... | ||
}, | ||
error(err){ | ||
// ... | ||
}, | ||
complete(res){ | ||
console.log(res) | ||
// ... | ||
} | ||
} | ||
|
||
var subscription = observable.subscribe(observer) // 上传开始 | ||
|
||
console.log(this.refs.upload.files) | ||
|
||
} | ||
|
||
render () { | ||
return ( | ||
<input | ||
ref="upload" | ||
className={Style['upload-image']} | ||
type="file" | ||
onChange={this.uploadFn} /> | ||
) | ||
} | ||
} | ||
|
||
Upload.defaultProps = { | ||
|
||
} | ||
export default Upload |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
@import '~@scss/mixin.scss'; | ||
|
||
:local(.upload-image){ | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
height: 100%; | ||
width: 100%; | ||
opacity:0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters