Utility Methods
checksum
Generates a checksum for a file in different hashing algorithms.
/**
* @path The file path
* @algorithm Default is MD5, but SHA-1, SHA-256, and SHA-512 can also be used.
*
* @throws cbfs.FileNotFoundException
*/
string function checksum( required path, algorithm = "MD5" );
// Example
disk.checksum( expandPath( "myFile.txt" ), "SHA-256" );chmod
Sets the access attributes of the file on Unix-based disks.
/**
* @path The file path
* @mode Access mode, the same attributes you use for the Linux command `chmod`
*
* @return cbfs.models.IDisk
*/
function chmod( required string path, required string mode );
// Example
disk.chmod( expandPath( "myFile.txt" ), "600" );createSymbolicLink
Creates a symbolic link in the system if it supports it. The target parameter is the target of the link. It may be an absolute or relative path and may not exist. When the target is a relative path, then file system operations on the resulting link are relative to the path of the link.
extension
Extract the extension from the file path
info
Returns information about the file. Will contain keys such as lastModified, size, path, name, type, canWrite, canRead, isHidden, and more depending on the provider used.
lastModified
Retrieves the file's last modified timestamp.
mimeType
Retrieves the file's mimetype.
size
Retrieves the size of the file in bytes.
temporaryUrl
Gets a temporary URI for the given file.
With the S3 provider, you can specify a struct of response headers to control the URL constructed. For example, to generate a URL that ensures a file is returned with the MIME type 'text/plain', you could pass that into temporaryURL().
url
Retrives the full url for a resource
Last updated
Was this helpful?