Authored by Targaryen

up-to-qiniu-modified

... ... @@ -104,17 +104,24 @@ class FileApi {
let fileKey = path.join(QINIU_PREFIX, path.relative(FILE_SAVE_ROOT_PATH, filepath));
return new Promise((resolve, reject) => {
qn.uploadFileAsync(filepath, {key:fileKey}).then(result => {
if (result && result.url) {
qn.uploadFile(filepath, {key:fileKey}, (err, result) => {
if (err) {
ws.broadcast(BROADCAST_PATH, {
state: `${fileKey} 上传到七牛成功`
state: `${fileKey} 上传到七牛过程中出现错误`
});
reject(err);
} else {
ws.broadcast(BROADCAST_PATH, {
state: `${fileKey} 上传到七牛失败`
});
if (result && result.url) {
ws.broadcast(BROADCAST_PATH, {
state: `${fileKey} 上传到七牛成功`
});
} else {
ws.broadcast(BROADCAST_PATH, {
state: `${fileKey} 上传到七牛失败`
});
}
resolve(result);
}
resolve(result);
});
});
});
... ...