|
@@ -3,44 +3,39 @@ import { Upload, Icon, Modal, message, Spin } from "antd";
|
3
|
3
|
import dayjs from "dayjs";
|
4
|
4
|
import shortid from "shortid";
|
5
|
5
|
import intl from "react-intl-universal";
|
6
|
|
-import {
|
7
|
|
- OSS_ENDPOINT,
|
8
|
|
- OSS_BUCKET,
|
9
|
|
- DRIVER_LICENSE_PATH,
|
10
|
|
- ERROR_DEFAULT
|
11
|
|
-} from "../../constant";
|
|
6
|
+import { DRIVER_LICENSE_PATH, ERROR_DEFAULT } from "../../constant";
|
12
|
7
|
import Comment from "../../Comment";
|
13
|
8
|
import "./Upload.css";
|
14
|
9
|
|
15
|
|
-const client = oss => {
|
16
|
|
- return new window.OSS.Wrapper({
|
17
|
|
- accessKeyId: oss.access_key_id,
|
18
|
|
- accessKeySecret: oss.access_key_secret,
|
19
|
|
- stsToken: oss.security_token,
|
20
|
|
- endpoint: OSS_ENDPOINT, //常量,你可以自己定义
|
21
|
|
- bucket: OSS_BUCKET
|
22
|
|
- });
|
23
|
|
-};
|
|
10
|
+// const client = oss => {
|
|
11
|
+// return new window.OSS.Wrapper({
|
|
12
|
+// accessKeyId: oss.access_key_id,
|
|
13
|
+// accessKeySecret: oss.access_key_secret,
|
|
14
|
+// stsToken: oss.security_token,
|
|
15
|
+// endpoint: OSS_ENDPOINT, //常量,你可以自己定义
|
|
16
|
+// bucket: OSS_BUCKET
|
|
17
|
+// });
|
|
18
|
+// };
|
24
|
19
|
|
25
|
|
-const uploadPath = (path, file) => {
|
26
|
|
- return `${path}/${dayjs().format("YYYYMMDD")}/${shortid.generate()}.${
|
27
|
|
- file.type.split("/")[1]
|
28
|
|
- }`;
|
29
|
|
-};
|
|
20
|
+// const uploadPath = (path, file) => {
|
|
21
|
+// return `${path}/${dayjs().format("YYYYMMDD")}/${shortid.generate()}.${
|
|
22
|
+// file.type.split("/")[1]
|
|
23
|
+// }`;
|
|
24
|
+// };
|
30
|
25
|
|
31
|
|
-const UploadToOss = (oss, path, file) => {
|
32
|
|
- const url = uploadPath(path, file);
|
33
|
|
- return new Promise((resolve, reject) => {
|
34
|
|
- client(oss)
|
35
|
|
- .multipartUpload(url, file)
|
36
|
|
- .then(data => {
|
37
|
|
- resolve(data);
|
38
|
|
- })
|
39
|
|
- .catch(error => {
|
40
|
|
- reject(error);
|
41
|
|
- });
|
42
|
|
- });
|
43
|
|
-};
|
|
26
|
+// const UploadToOss = (oss, path, file) => {
|
|
27
|
+// const url = uploadPath(path, file);
|
|
28
|
+// return new Promise((resolve, reject) => {
|
|
29
|
+// client(oss)
|
|
30
|
+// .multipartUpload(url, file)
|
|
31
|
+// .then(data => {
|
|
32
|
+// resolve(data);
|
|
33
|
+// })
|
|
34
|
+// .catch(error => {
|
|
35
|
+// reject(error);
|
|
36
|
+// });
|
|
37
|
+// });
|
|
38
|
+// };
|
44
|
39
|
|
45
|
40
|
class App extends React.Component {
|
46
|
41
|
constructor(props) {
|
|
@@ -94,7 +89,8 @@ class App extends React.Component {
|
94
|
89
|
reader.onloadend = () => {
|
95
|
90
|
info.onProgress({ percent: 20 });
|
96
|
91
|
// DRIVER_LICENSE_PATH oss 的存储路径位置
|
97
|
|
- UploadToOss(this.props.app.oss, DRIVER_LICENSE_PATH, file)
|
|
92
|
+ this.props.app
|
|
93
|
+ .UploadToOss(this.props.app.oss, DRIVER_LICENSE_PATH, file)
|
98
|
94
|
.then(data => {
|
99
|
95
|
info.onProgress({ percent: 100 });
|
100
|
96
|
info.onSuccess(data);
|