FileInfo / SearchFolderOptions — k.file
File and folder metadata objects and folder search options for
k.file
| Execution Context | Prerequisites | Typical Use |
|---|---|---|
Server-side KScript (k.api, <script env="server">, scheduled jobs) | Returned by k.file methods or passed into k.file.folderFiles() | Inspect file sizes, URLs, and timestamps, and filter recursive folder listings |
Quick Start
Read FileInfo metadata via k.file.get(), and filter k.file.folderFiles() using SearchFolderOptions:
js
k.api.get(() => {
const info = k.file.get("uploads/report.txt")
const matched = k.file.folderFiles("uploads", {
includeAllDirectories: true,
searchPattern: "*.txt"
})
return {
file: info ? { name: info.name, size: info.size, url: info.relativeUrl } : null,
matchedNames: matched.map((item) => item.fullName)
}
})Quick Reference
| Method / Property | Description | Returns |
|---|---|---|
FileInfo | File metadata object returned by write, writeBinary, get, load, folderFiles, getAllFiles, and build | FileInfo |
FolderInfo | Folder name and full path object returned by subFolders() | FolderInfo |
SearchFolderOptions | Optional search filter (searchPattern, recursion, author) passed to k.file.folderFiles() | SearchFolderOptions |
FileInfo Property
| Property | Description | Type |
|---|---|---|
name | File name | string |
fullName | Full storage path | string |
size | File size (bytes) | number |
stringSize | Formatted file size string | string |
relativeUrl | Relative URL | string |
absoluteUrl | Absolute URL | string |
url | Access URL (same as relativeUrl) | string |
lastModified | Last modified time | Date |
authorUserName | Author username | string |
FolderInfo Property
| Property | Description | Type |
|---|---|---|
name | Folder name | string |
fullName | Full folder path | string |
SearchFolderOptions Property
| Property | Description | Type |
|---|---|---|
includeAuthor | Whether to include author information | boolean |
includeAllDirectories | Whether to include all subdirectories recursively | boolean |
searchPattern | Search pattern, defaults to *.* | string |
TypeScript Definitions
ts
interface FileInfo {
name: string;
fullName: string;
size: number;
stringSize: string;
relativeUrl: string;
absoluteUrl: string;
url: string;
lastModified: Date;
authorUserName: string;
}
interface FolderInfo {
name: string;
fullName: string;
}
interface SearchFolderOptions {
includeAuthor?: boolean;
includeAllDirectories?: boolean;
searchPattern?: string;
}Related Docs
- k.file — Core file operations
- Folder Operations — k.file — Directory CRUD and listings
- k.file.resumableUpload — Resumable upload