Skip to content


Random string path should be regenerated by JavaScript for each file #72

uberllama opened this Issue · 1 comment

2 participants


I've run into an issue where uploads with the same file name are over writing each other, because the same server-generated path is being used for every file. This is particularly problematic for mobile uploads, where every photo from your camera roll gets named image.jpg by iOS.

A unique path should be generated for every upload:

key: "uploads/${JavaScript generated path}/${filename}"

Could we use the existing uniqueid js var? I'm currently looking into if it could be appended when generating the data path in the formData method.


I've just figured it out and will be making a pull request within the next few days. The new formData will look something like this:

      formData: (form) ->
        data = form.serializeArray()
        fileType = ""
        if "type" of @files[0]
          fileType = @files[0].type
          name: "Content-Type"
          value: fileType
        data[1].value = settings.path + "uploads/" + @files[0].unique_id + data[1].value #the key

Note in the second last line that the file's unique ID will be used as the random string for the upload, instead of passing in the same SecureRandom from the server for all files. I'll probably also prefix a date.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.