Giter VIP home page Giter VIP logo

Comments (4)

tbunique avatar tbunique commented on July 23, 2024 1

I see what you mean.

I do have that extra logic elsewhere:

  • Browser sends initial request to other server
  • I check auth and return path to folder where user can upload their file
  • Browser initiates real transfer request to tus server and also sends filename and path with the metadata (path is protected with hmac so user can't tamper with it)
  • Naming function is used to put the file with real name in correct folder

I should have put my complete code in my initial example, apologies.

from tus-node-server.

Murderlon avatar Murderlon commented on July 23, 2024

Hi, you shouldn't use namingFunction to change the default unique ID to a non-unique file name. This will cause file corruption sooner or later if people upload files with the same name!

What probably makes most sense is to have #594, then you can change the file name in the metadata and the store will save that new metadata. You can keep the actual files uniquely generated. In tus in generally works like this, original file name in the .info or .json file and a unique file adjacent to it.

Performing a HEAD request will send back the metadata whenever the client likes to know it.

from tus-node-server.

tbunique avatar tbunique commented on July 23, 2024

I see, thanks 👍

I'm starting to think maybe tus is not the best for my use case. I want users to be able to overwrite existing files as they handle their own files. That's why I need to display the real file names without doing any HEAD requests (or querying my db where I would have stored the real hierarchy).

from tus-node-server.

Murderlon avatar Murderlon commented on July 23, 2024

You can override files, you just want to do it safely and explicitly. If you only use namingFunction without extra logic that puts each user's files in their own folder, a user can corrupt other user's files.

You can remove the old file in onUploadFinish to "override" it. But as of now, you would need to perform a HEAD to see the changes. It's not ideal but it's not going to be a problem either I reckon.

In a future version of the tus spec, it would be nice to send back Upload-Metadata in the POST request.

from tus-node-server.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.