Showing
1 changed file
with
14 additions
and
7 deletions
@@ -104,17 +104,24 @@ class FileApi { | @@ -104,17 +104,24 @@ class FileApi { | ||
104 | let fileKey = path.join(QINIU_PREFIX, path.relative(FILE_SAVE_ROOT_PATH, filepath)); | 104 | let fileKey = path.join(QINIU_PREFIX, path.relative(FILE_SAVE_ROOT_PATH, filepath)); |
105 | 105 | ||
106 | return new Promise((resolve, reject) => { | 106 | return new Promise((resolve, reject) => { |
107 | - qn.uploadFileAsync(filepath, {key:fileKey}).then(result => { | ||
108 | - if (result && result.url) { | 107 | + qn.uploadFile(filepath, {key:fileKey}, (err, result) => { |
108 | + if (err) { | ||
109 | ws.broadcast(BROADCAST_PATH, { | 109 | ws.broadcast(BROADCAST_PATH, { |
110 | - state: `${fileKey} 上传到七牛成功` | 110 | + state: `${fileKey} 上传到七牛过程中出现错误` |
111 | }); | 111 | }); |
112 | + reject(err); | ||
112 | } else { | 113 | } else { |
113 | - ws.broadcast(BROADCAST_PATH, { | ||
114 | - state: `${fileKey} 上传到七牛失败` | ||
115 | - }); | 114 | + if (result && result.url) { |
115 | + ws.broadcast(BROADCAST_PATH, { | ||
116 | + state: `${fileKey} 上传到七牛成功` | ||
117 | + }); | ||
118 | + } else { | ||
119 | + ws.broadcast(BROADCAST_PATH, { | ||
120 | + state: `${fileKey} 上传到七牛失败` | ||
121 | + }); | ||
122 | + } | ||
123 | + resolve(result); | ||
116 | } | 124 | } |
117 | - resolve(result); | ||
118 | }); | 125 | }); |
119 | }); | 126 | }); |
120 | }); | 127 | }); |
-
Please register or login to post a comment