UUID Use Case

UUID Filename

User-supplied filenames collide and can contain paths or sensitive words. A UUID filename is unique and inert.

UniquePath-safeOpaque

Generated locally with the Web Crypto API — nothing leaves your browser.

What Is UUID Filename?

How to generate

  1. Generate a v4 UUID as the stored filename.
  2. Keep the original name in metadata for display.
  3. Add an extension based on content type.

Use Cases

Code Examples

JavaScript
const name = crypto.randomUUID() + path.extname(original);
await fs.writeFile(`/uploads/${name}`, buf);

Frequently Asked Questions

Keep the original filename?
Store it separately for display, but use the UUID on disk to avoid collisions and traversal.
Add an extension?
Yes — derive it from the detected MIME type, not from the user-supplied name.

Related tools