Function-based resolver
Wraps a custom resolution function as a FileUrlResolver. Most flexible option for custom logic.
const resolver = new FunctionResolver((path, ctx) => { if (path.startsWith('http')) return path; return `https://api.example.com/files/${ctx.projectId}/${path}`;}); Copy
const resolver = new FunctionResolver((path, ctx) => { if (path.startsWith('http')) return path; return `https://api.example.com/files/${ctx.projectId}/${path}`;});
Resolve a file path to a full URL
The file path to resolve (can be relative or absolute)
Additional context for resolution (e.g., projectId)
The full URL to load the file from
// Relative pathconst url = resolver.resolve('model.glb', { projectId: '123' });// => 'http://localhost:3000/api/projects/123/files/model.glb'// Absolute path (pass through)const url = resolver.resolve('http://example.com/model.glb', {});// => 'http://example.com/model.glb' Copy
// Relative pathconst url = resolver.resolve('model.glb', { projectId: '123' });// => 'http://localhost:3000/api/projects/123/files/model.glb'// Absolute path (pass through)const url = resolver.resolve('http://example.com/model.glb', {});// => 'http://example.com/model.glb'
Private
Function-based resolver
Wraps a custom resolution function as a FileUrlResolver. Most flexible option for custom logic.
Example