Every image chosen from the user will be stored in Amazon S3 this is my code
key: function ( file ) {
var user = Meteor.users.findOne( this.userId );
return user.emails[0].address + "/screenshots" + "/" + file.name;
}
Based on my code, the image will be stored in the user's email directory then the screenshots folder then the file name. the problem is if the user wanted to store two images of the same name. The last picture will overwrite the first one.
i tried this solution
key: function ( file ) {
var today = new Date();
var user = Meteor.users.findOne( this.userId );
return user.emails[0].address + "/screenshots" + "/" + today + file.name;
}
it didn't work because the current date have spaces so i can't load the image later in the client because of the spaces.
Any idea of a way i can use to give every image a unique name? with no spaces?