Sopamo / laravel-filepond

Laravel backend module for filepond uploads
MIT License
204 stars 54 forks source link

Allow save, get and delete of the original filename in cache #6

Closed booni3 closed 4 years ago

booni3 commented 5 years ago

I needed a way to get the original filename of the uploaded file. I am sure there are a few ways to do this. It could probably be done on the client side, but when uploading multiple files we would need a way to link each of the serverId's back to the filename. I also tried by storing in the session but this is not possible due to the API route, I believe. I have therefore chosen to save the filename into the Cache with a 60 minute expiry. This is working well for my purpose so thought I would share and get your thoughts.

Sopamo commented 5 years ago

I think this should probably be done on the client side. I'd have to look into it to see how to associate the uploaded file with the original file on the client side, but that should be possible.

mikemand commented 4 years ago

Hi, any news on this? I also need to get the original file name(s) of whatever is uploaded. I can enable the file rename plugin so the end-user can set their own file name, but this package completely ignores the name (as well as the original filename) because of the use of tempnam.

Edit: Why are you using tempnam anyway? The filename is encrypted before being sent to the client already. Could we use that to generate a unique filename?

LTroya commented 4 years ago

@mikemand You can get that information from UploadedFile instance

Sopamo commented 4 years ago

The workflow is intended to be like:

  1. Frontend uploads a file and receives a unique identifier for it (done by this package)
  2. Frontend collects any additional information needed to process the request (filenames, other data related to the file, etc)
  3. Frontend sends the unique identifier + additional information to the server (your controller)
  4. Your controller gets the file by it's unique identifier and stores it in the final location and also handles the additional information.

There is no need to store any real information about the file in step 1 as everything else should be handled by your frontend/backend code.