socketio-file-upload icon indicating copy to clipboard operation
socketio-file-upload copied to clipboard

Upload mutiple files?

Open adummy832 opened this issue 5 years ago • 4 comments

Is there any way to upload multiple files in a single go and save them in different directories using supplied metadata?

Referenced some useful link/s here:

  • https://stackoverflow.com/questions/46857545/using-socketio-file-upload-to-upload-multiple-files

adummy832 avatar Apr 10 '19 03:04 adummy832

I posted an answer on that StackOverflow question. However, this seems like a reasonable feature to add, and it wouldn't be too hard. Here's how I'd do it (all changes in client.js):

  • listenOnSubmit:
    • pass input as the second argument to _baseFileSelectCallback
  • _baseFileSelectCallback:
    • add a second argument named element
    • pass it to the "choose" event in the object literal: element: element
    • note: if element is undefined (not passed to _baseFileSelectCallback), then that value will be undefined in the object literal, which is fine

sffc avatar Apr 10 '19 06:04 sffc

Oh, and then the answer would be adding a listener on the "choose" event in userland, which would now have access to the file metadata and can add information based on the element the input came from.

In terms of saving the files in different directories, no, that's not going to be possible right now. However, if you add the information you want to the file.meta, you can just move the files on the server after they are finished uploading.

sffc avatar Apr 10 '19 06:04 sffc

If you want to make a PR, I'll be happy to review it for you.

sffc avatar Apr 10 '19 06:04 sffc

I wasn't expecting @sffc would reply within a day! 😎 Btw, thanks for this dude! Really loving this library 🎉 Right now i'm workin' on some stuff but i'll submit a PR. Thanks again. 👌

adummy832 avatar Apr 10 '19 07:04 adummy832