@coursebuilder/utils-file
v1.0.0
Published
File utilities for the CourseBuilder monorepo.
Readme
@coursebuilder/utils-file
File utilities for the CourseBuilder monorepo.
Installation
pnpm add @coursebuilder/utils-fileUsage
getUniqueFilename
Generates a unique filename by adding a random ID and cleaning the string for compatibility with services like S3.
Parameters
fullFilename- The original filename including extension
Returns
A unique filename with the same extension, cleaned for S3 compatibility.
Example
import { getUniqueFilename } from '@coursebuilder/utils-file/get-unique-filename'
// Returns something like "my-image-a1b2c3.jpg"
getUniqueFilename('my image.jpg')Contributing
To add a new utility to this package:
- Create a new file in the
srcdirectory - Implement your utility with proper TSDoc comments
- Export it from the package by updating
package.json - Add tests in a corresponding
.test.tsfile - Build and test your changes:
cd packages/utils-file
pnpm build
pnpm test