Image Uploads
Description
Drag images (JPG, GIF or PNG) onto the canvas to add them to the whiteboard. Images are saved to disk into a directory with the name name as the board JSON file.
Notable Code Changes
- Use new class
BoardDataListinstead of plain JS object forboardsinsocketsmodule.- Provides access to the boards list via functions which allows for better access control and observability. This is desirable now that multiple objects may attempt to mutate the data.
- Add new dependency
multipartyfor parsingFormDataon server.
TODO
- [x] Delete images when removed from the board
- [x] Support clicking on canvas with image tool to add image
- [x] Delete tmp file after uploading image
- [x] Address possible security issue here
- [x] When serving board image assets, don't block handler function
Future Improvements
- [ ] Display upload progress indicator for image
- [ ] Support for "Download Image"
Thank you very much for contributing this long-requested feature !
I'll try to review it soon, but before:
- can we add tests ? This is a sensitive feature with big security implications, I think it needs tests.
- the image upload endpoint needs to be disabled when the image tool is disabled (using
BLOCKED_TOOLS)
I see there are also still TODOs in the code. Feel free to switch it back to ready for review when you are ready for me to have a look
Progress update: I've added some tests but for some reason I can't get them to pass in FireFox (though they pass fine in Chromium).
Great to see progress ! I don't have a lot of time to spend on wbo at the moment, but I'm determined to merge this once we are confident it works, is secure and maintainable !