mirror of
https://github.com/wekan/wekan.git
synced 2025-12-23 19:00:12 +01:00
REST API: List attachments of a board.
For using this, Python code example: https://github.com/wekan/wekan/wiki/New-card-with-Python3-and-REST-API Thanks to xet7 ! Related #1482
This commit is contained in:
parent
573426899a
commit
bf94161f30
1 changed files with 35 additions and 0 deletions
|
|
@ -1753,6 +1753,41 @@ if (Meteor.isServer) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//ATTACHMENTS REST API
|
||||||
|
/**
|
||||||
|
* @operation get_board_attachments
|
||||||
|
* @summary Get the list of attachments of a board
|
||||||
|
*
|
||||||
|
* @param {string} boardId the board ID
|
||||||
|
* @return_type [{attachmentId: string,
|
||||||
|
* attachmentName: string,
|
||||||
|
* attachmentType: string,
|
||||||
|
* cardId: string,
|
||||||
|
* listId: string,
|
||||||
|
* swimlaneId: string}]
|
||||||
|
*/
|
||||||
|
JsonRoutes.add('GET', '/api/boards/:boardId/attachments', function(req, res) {
|
||||||
|
const paramBoardId = req.params.boardId;
|
||||||
|
Authentication.checkBoardAccess(req.userId, paramBoardId);
|
||||||
|
JsonRoutes.sendResult(res, {
|
||||||
|
code: 200,
|
||||||
|
data: Attachments.files
|
||||||
|
.find({ boardId: paramBoardId }, { fields: { boardId: 0 } })
|
||||||
|
.map(function(doc) {
|
||||||
|
return {
|
||||||
|
attachmentId: doc._id,
|
||||||
|
// this preserves the name so that notifications can be meaningful after
|
||||||
|
// this file is removed
|
||||||
|
attachmentName: doc.original.name,
|
||||||
|
attachmentType: doc.original.type,
|
||||||
|
cardId: doc.cardId,
|
||||||
|
listId: doc.listId,
|
||||||
|
swimlaneId: doc.swimlaneId,
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Boards;
|
export default Boards;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue