Skip to content
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

rename file name before upload to s3 #722

Closed
vikksr opened this issue Oct 14, 2014 · 5 comments
Closed

rename file name before upload to s3 #722

vikksr opened this issue Oct 14, 2014 · 5 comments

Comments

@vikksr
Copy link

vikksr commented Oct 14, 2014

I am submitting directly to s3 using dropzone.js. it works great except when the file name has spaces in it. Is there any way to change the file name before submitting to s3 (url friendly filename)??

@tomauty
Copy link

tomauty commented Nov 4, 2014

edit - I was wrong

@pmanavi
Copy link

pmanavi commented Dec 29, 2014

Anyway that you can share the code you would use inside the processing event? I have just file.name = "somenewname" but I don't think thats correct because its not working. Thanks.

@tomauty
Copy link

tomauty commented Dec 29, 2014

Looks like the File object's name property is read-only after some more research. Are you uploading straight to s3 from the browser?

@pmanavi
Copy link

pmanavi commented Dec 29, 2014

Not sure what you mean by S3, but I did manage to track an ID number using a hidden form variable and setting its value in the success routine. However, that only works for maxfiles set to just 1. For this project, I only allow for 1 file to be dropped so it works for me for now, but it would be great if I could have a solution for a future project that needs to track multiple files.

I'm not very savvy in javascript, but if I could figure a way to create a new variable for each item that I could access much like we do with file.name (something like file.ID) then that would solve the issue. I just don't know javascript well enough to do it.

@pmanavi
Copy link

pmanavi commented Dec 30, 2014

Actually, just figured out how to make this work with multiple files as well. Basic function is to create a dynamic hidden field upon the successful completion of each upload with the id/name based on the file.name but encoded for spaces and etc, an then using the file.name field in the removal process to recreate the encoded field name and then reading its value into a variable. That variable can be an ID, different name or what ever. Let me know if you want to see my code. It works great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants