-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is it possible to rename the file before upload? #138
Comments
Please, see third item of faq |
@nervgh - looking at the faq, which leads to this comment #97 (comment) I'm a little confused. From what I can see, there's no actual way to edit Just so I'm clear, what you're suggesting is to edit |
Figured it out doing exactly that (setting That said, it would be nice to know that you can't just change the |
@davidwparker I am directly uploading to amazon S3 after receiving a signed signature from my nodejs server. I ultimately decided to auto increment the directory name and keep the original file name in-tact. ie uploads/12/businessModel.doc, uploads/13/businessModel.doc. I think this is how asana decided to to prevent naming collisions. |
You can use |
I want to just leave a solution here, because @nervgh 's comments didn't help for me, item.alias didn't work, and the docs/faq didn't help. The solution is to change item.file.name, here is a small function that works well: uploader.onAfterAddingFile = function(item) {
var fileExtension = '.' + item.file.name.split('.').pop();
item.file.name = Math.random().toString(36).substring(7) + new Date().getTime() + fileExtension;
}; When you process the upload of the file, it should get renamed correctly. there is an item._file that has all of the original attributes that is used during the upload. |
Thanks @hellsan631 ... it worked for me! |
Thanks @hellsan631 👍 |
Not works on IE9. |
There's a nastier problem here though in that you can have users uploading files with character that will break AWS links. Files like |
yes! I am in this case :
this fails (api call level, on answer, it is pending until timeout) because the variable File is just a pointer of some sort to actual computer file access and renaming it's name means that the File won't be found on the disk (without JS or angular errors, without any errors at all). This is pretty stupid. I'm actually fine with renaming the user's file on disk before upload. the user is stupid and needs to have his hand held. |
Thank you very much! @hellsan631 |
Okay I am struggling to understand this. it would be glad if someone helps me here. my file name is |
No description provided.
The text was updated successfully, but these errors were encountered: