whitebophir icon indicating copy to clipboard operation
whitebophir copied to clipboard

Image Uploads

Open atomdmac opened this issue 2 years ago • 4 comments

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 BoardDataList instead of plain JS object for boards in sockets module.
    • 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 multiparty for parsing FormData on 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"

atomdmac avatar Nov 18 '23 16:11 atomdmac

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)

lovasoa avatar Nov 18 '23 19:11 lovasoa

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

lovasoa avatar Nov 18 '23 19:11 lovasoa

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).

atomdmac avatar Nov 27 '23 14:11 atomdmac

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 !

lovasoa avatar Nov 27 '23 16:11 lovasoa