Commit ce847c38 authored by strong's avatar strong

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

parent 9bcf31a3
...@@ -93,21 +93,36 @@ function handleUpload(req, uploadfile, storageType, targetPath, callback) { ...@@ -93,21 +93,36 @@ function handleUpload(req, uploadfile, storageType, targetPath, callback) {
'Cache-Control': 'max-age=86400' 'Cache-Control': 'max-age=86400'
}; };
filePath = 'upload/' + filePath; filePath = 'upload/' + filePath;
var fileSavePath = '/oss/' + filePath;
var url = isDebug === true ? env.ossConfig.devCDNURL : env.ossConfig.prodCDNURL; var url = isDebug === true ? env.ossConfig.devCDNURL : env.ossConfig.prodCDNURL;
ofs.uploadFile(uploadfile.path, filePath, metadata, function(err) { // ofs.uploadFile(uploadfile.path, filePath, metadata, function(err) {
if (err) { // if (err) {
console.log(err); // console.log(err);
callback(err, null); // callback(err, null);
} else { // } else {
callback(null, { // callback(null, {
originalName: uploadfile.name, // originalName: uploadfile.name,
fileName: filePath, // fileName: filePath,
fileType: uploadfile.type, // fileType: uploadfile.type,
fileSize: uploadfile.size, // fileSize: uploadfile.size,
urlFileName: url + filePath, // urlFileName: url + filePath,
fieldName: uploadfile.fieldName // 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