In a textarea, people can paste pictures. I handle that with AngularJS, the ng-paste
directive and this piece of code
ctrl.handlePaste = function(event) {
if(event.clipboardData.items.length > 0) {
for(var i = 0; i < event.clipboardData.items.length; i++) {
var item = event.clipboardData.items[i]; // type: DataTransferItem
if (item.type.indexOf("image") != -1) {
file = item.getAsFile(); // type: File
// it's then stored in a array and will be sent to the server
break;
}
}
}
}
Then I send it to my Flask server (Python 2.7) and it is then sent by emails or pushed via API to another service.
On server side I've checked the type and it's a Flask FileStorage
.
My problem is: this file is automatically named "image.png" (I'm using Chrome) and I cant find a way to change this name during the process.
I'm ok with changing it on front side (my favourite option), I'm ok on server side too.