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
pull/3382/head
Lauri Ojansivu 5 years ago
parent 573426899a
commit bf94161f30
  1. 35
      models/boards.js

@ -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;

Loading…
Cancel
Save