reflex-dev / reflex

🕸️ Web apps in pure Python 🐍
https://reflex.dev
Apache License 2.0
20.37k stars 1.17k forks source link

CTRL+V files from clipboard into rx.upload #2806

Open Anga205 opened 8 months ago

Anga205 commented 8 months ago

i was wondering if its possible for a new feature to be added to rx.upload wherein if a user has a file (like a screenshot) stored in their clipboard, they can press ctrl+v onto a rx.upload component and it recieves/uploads the file to the website, it would look something like this: Screencast from 2024-03-07 11-53-14.webm

picklelo commented 8 months ago

Seems like a cool feature, we don't have it in the internal roadmap currently but we would accept an outside contribution for this.

SwarajBaral commented 7 months ago

I would like to work on this, could you maybe help me get started here ? I understand that I need to somehow use the blob that's in the clipboard and use it as an upload ?

picklelo commented 7 months ago

@SwarajBaral I'm not too sure what the approach is here actually, I'm guessing we need to have some sort of listener on the upload component for ctrl+v on which we trigger the clipboard upload. But I'm not sure how that listener would hook up. If we can trigger an action on the ctrl+v then we can probably run some JS to add to the upload.

We use react-dropzone under the hood for upload, looks like someone has found a way to do this on this issue that we can use for inspiration: https://github.com/react-dropzone/react-dropzone/issues/1210