Skip to main content

Uploads configurations

Uploads are essential for any application, this section will cover the uploads configurations to give you a better control over how files are being uploaded and transformed.

Save To Directory

All files are stored inside storage directory under the uploads directory storage/uploads for security reasons, for now you can set the default relative path to this path.

The default path for any uploaded file is DD-MM-YYYY/{Hash} directory, but you can change this behavior by setting the saveTo property to a function that returns the path to save the file to.

src/config/uploads.ts
import { UploadsConfigurations, requestContext } from "@warlock.js/core";

const uploadsConfigurations: UploadsConfigurations = {
/**
* The default path to save the uploaded files
*/
saveTo: () => {
return "files";
},
};

export default uploadsConfigurations;

Compressing images

Compressing images will convert any image type into webp, this will reduce the image size significantly and save the storage space, a better performance will be achieved as well.

For more information about compressing images, please refer to Compressing images.