bkad / prat

group chat with markdown served over websockets

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Drag'n'drop image upload

cespare opened this issue · comments

This would be sexy as hell. We'd have to store the images ourselves (mongo handles that kind of thing fine, right?)

We could store the message id with the image and periodically wipe images if the corresponding message has been evicted from the mongo collection.

I think the right way to do this is to offload the work to imgur. They have an API with rate limits north of 1000 uploads per day: http://api.imgur.com/endpoints/image.

The way that this would work is that we enable drag and drop on the chat-text area and when an image is dropped we either use the path and file pointer we're given to immediately trigger an imgur upload request or cache the image in local storage and use imgur's base64 upload endpoint to do things in the background.

There will probably be some complexity involved in figuring out how all this should look to a remote user who gets markdown that's rendering ![img](i.imgur.com/foo) but the image hasn't been uploaded to imgur yet.