bkad / prat

group chat with markdown served over websockets
11 stars 6 forks source link

Drag'n'drop image upload #82

Closed cespare closed 10 years ago

cespare commented 11 years ago

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.

mdietz commented 11 years ago

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.

bkad commented 11 years ago

could also use s3 and generalize for other filetypes

http://philfreo.com/blog/how-to-allow-direct-file-uploads-from-javascript-to-amazon-s3-signed-by-python/