Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pisns-forum-api
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
scrmGroup
pisns-forum-api
Commits
ce847c38
Commit
ce847c38
authored
Apr 29, 2016
by
strong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
生产环境的文件上传oss改用本地上传映射目录
parent
9bcf31a3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
14 deletions
+29
-14
uploadfile.js
app/utils/uploadfile.js
+29
-14
No files found.
app/utils/uploadfile.js
View file @
ce847c38
...
@@ -93,12 +93,27 @@ function handleUpload(req, uploadfile, storageType, targetPath, callback) {
...
@@ -93,12 +93,27 @@ 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, {
// 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
,
{
callback
(
null
,
{
originalName
:
uploadfile
.
name
,
originalName
:
uploadfile
.
name
,
fileName
:
filePath
,
fileName
:
filePath
,
...
@@ -107,7 +122,7 @@ function handleUpload(req, uploadfile, storageType, targetPath, callback) {
...
@@ -107,7 +122,7 @@ function handleUpload(req, uploadfile, storageType, targetPath, callback) {
urlFileName
:
url
+
filePath
,
urlFileName
:
url
+
filePath
,
fieldName
:
uploadfile
.
fieldName
fieldName
:
uploadfile
.
fieldName
});
});
}
});
});
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment