明树Git Lab
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
L
letian_backend
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zengfanpei
letian_backend
Commits
fbd4a2bf
Commit
fbd4a2bf
authored
Sep 13, 2024
by
zengfanpei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
1dec7a9e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
1 deletion
+21
-1
fileController.js
controller/fileController.js
+20
-0
fileRouter.js
router/fileRouter.js
+1
-1
No files found.
controller/fileController.js
View file @
fbd4a2bf
...
...
@@ -18,6 +18,25 @@ async function upload(req, res, next) {
next
(
error
);
}
}
async
function
batchUpload
(
req
,
res
,
next
)
{
try
{
let
ret
=
[];
for
(
let
index
=
0
;
index
<
req
.
files
.
length
;
index
++
)
{
const
element
=
req
.
files
[
index
];
ret
.
push
({
originalname
:
element
.
originalname
,
mimetype
:
element
.
mimetype
,
filename
:
element
.
filename
,
path
:
element
.
path
,
size
:
element
.
size
,
})
}
let
data
=
await
DB
.
File
.
insertMany
(
ret
);
res
.
sendData
(
data
);
}
catch
(
error
)
{
next
(
error
);
}
}
...
...
@@ -68,5 +87,6 @@ async function importExcel(req, res, next) {
module
.
exports
=
{
upload
,
batchUpload
,
importExcel
}
\ No newline at end of file
router/fileRouter.js
View file @
fbd4a2bf
...
...
@@ -32,7 +32,7 @@ const upload = multer({ storage: storage })
router
.
post
(
'/upload'
,
upload
.
single
(
'file'
),
fileController
.
upload
);
// router.post('/')
router
.
post
(
'/batch/upload'
,
upload
.
array
(
'files'
),
fileController
.
batchUpload
);
// 文件访问: 起nginx用以处理文件服务器。
...
...
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