|
@@ -261,6 +261,7 @@ module.exports = (crowi: Crowi): Router => {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
// TODO: verify transfer key
|
|
// TODO: verify transfer key
|
|
|
|
|
+ // This endpoint uses multer's MemoryStorage since the received data should be persisted directly on attachment storage.
|
|
|
receiveRouter.post('/attachment', uploadsForAttachment.single('content'), /* verifyAndExtractTransferKey, */
|
|
receiveRouter.post('/attachment', uploadsForAttachment.single('content'), /* verifyAndExtractTransferKey, */
|
|
|
async(req: Request & { transferKey: TransferKey }, res: ApiV3Response) => {
|
|
async(req: Request & { transferKey: TransferKey }, res: ApiV3Response) => {
|
|
|
const { file } = req;
|
|
const { file } = req;
|
|
@@ -275,6 +276,8 @@ module.exports = (crowi: Crowi): Router => {
|
|
|
return res.apiv3Err(new ErrorV3('Failed to parse body.', 'parse_failed'), 500);
|
|
return res.apiv3Err(new ErrorV3('Failed to parse body.', 'parse_failed'), 500);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // convert Buffer to stream
|
|
|
|
|
+ // see: https://stackoverflow.com/a/62143160
|
|
|
await g2gTransferReceiverService.receiveAttachment(Readable.from(file.buffer), attachmentMap);
|
|
await g2gTransferReceiverService.receiveAttachment(Readable.from(file.buffer), attachmentMap);
|
|
|
|
|
|
|
|
return res.apiv3({ message: 'Successfully imported attached file.' });
|
|
return res.apiv3({ message: 'Successfully imported attached file.' });
|