nodebb-plugin-imgur icon indicating copy to clipboard operation
nodebb-plugin-imgur copied to clipboard

.uploadDataURI

Open julianlam opened this issue 11 years ago • 1 comments

The expected input for .upload() seems to be either: { image: { url: 'http://...' } } or { image: { path: '/path/to/file' } }, with name optionally provided as a property in image.

I'd like to send a data URI straight to the plugin, because that's how I get the data (not via form file upload), and it would reduce my steps from:

HTML5 File API -> socket.emit() -> groups.updateCover() -> generate-md5sum -> save-to-disk -> uploader.uploadImage() -> imgur.upload() -> delete-temporary-file

to...

HTML5 File API -> socket.emit() -> groups.updateCover() -> uploader.uploadImage() -> imgur.upload()

Could continue to overload .upload() to handle data URI, up to you.

I imagine in core, we'd change .uploadImage() to handle data URI's being passed in, although we'd introduce a new hook for Data URI uploads in case the plugins can't handle that.

Bonus points if you manage to do this via Node.js Streams :smile:

julianlam avatar Jan 15 '15 15:01 julianlam

Imgur API accepts base64 data

julianlam avatar Jan 15 '15 15:01 julianlam