Page MenuHomeSealhub

image-value.ts
No OneTemporary

Authored By
Unknown
Size
858 B
Referenced Files
None
Subscribers
None

image-value.ts

import type { PathFilePointer } from "@sealcode/file-manager";
import type { FieldValue } from "./field-value.js";
type RestPreference = "relative" | "absolute";
export class ImageValue implements FieldValue {
constructor(
private readonly file: PathFilePointer,
private readonly base_url: string,
private readonly restPreference: RestPreference
) {}
toFile(): PathFilePointer {
return this.file;
}
async toPath(): Promise<string> {
return this.file.getPath();
}
async getPath(): Promise<string> {
return this.toPath();
}
toUrl(with_host: boolean = true): string {
return `${with_host ? this.base_url : ""}${this.file.getURL()}`;
}
toString(): string {
return this.toUrl(true);
}
getRestAPIValue(): string | PathFilePointer {
return this.restPreference === "absolute"
? this.toUrl(true)
: this.toUrl(false);
}
}

File Metadata

Mime Type
application/javascript
Expires
Fri, Nov 27, 16:05 (1 d, 15 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1213041
Default Alt Text
image-value.ts (858 B)

Event Timeline