Commit ce847c38 authored by strong's avatar strong

生产环境的文件上传oss改用本地上传映射目录

parent 9bcf31a3
......@@ -93,21 +93,36 @@ function handleUpload(req, uploadfile, storageType, targetPath, callback) {
'Cache-Control': 'max-age=86400'
};
filePath = 'upload/' + filePath;
var fileSavePath = '/oss/' + filePath;
var url = isDebug === true ? env.ossConfig.devCDNURL : env.ossConfig.prodCDNURL;
ofs.uploadFile(uploadfile.path, filePath, metadata, function(err) {
if (err) {
console.log(err);
callback(err, null);
} else {
callback(null, {
originalName: uploadfile.name,
fileName: filePath,
fileType: uploadfile.type,
fileSize: uploadfile.size,
urlFileName: url + filePath,
fieldName: uploadfile.fieldName
});
}
// ofs.uploadFile(uploadfile.path, filePath, metadata, function(err) {
// if (err) {
// console.log(err);
// callback(err, null);
// } else {
// callback(null, {
// originalName: uploadfile.name,
// fileName: filePath,
// fileType: uploadfile.type,
// fileSize: uploadfile.size,
// urlFileName: url + filePath,
// fieldName: uploadfile.fieldName
// });
// }
// });
console.log('targetPath:' + fileSavePath);
fse.move(uploadfile.path, fileSavePath, function(err) {
console.error('error:' + err);
if (err) throw callback(err, null);
callback(null, {
originalName: uploadfile.name,
fileName: filePath,
fileType: uploadfile.type,
fileSize: uploadfile.size,
urlFileName: url + filePath,
fieldName: uploadfile.fieldName
});
});
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment