FilePath
File Path input.
const input = Input.create('myInput: filePath');
input.setValue('/tmp/foo.txt');
Property Summary
Property Name | Description | Defined by Default | Default Value |
---|---|---|---|
restrictWebAccess | boolean telling if the input should have restrict access when handling requests. When enabled it only lets the input to be set by a file upload, making sure that the input cannot be set otherwise (like through a string) | ![]() |
![]() |
maxFileSize | maximum file size in bytes | ![]() |
![]() |
exists | checks if the file path exists | ![]() |
![]() |
allowedExtensions | specific list of extensions allowed by the input (this check is case insensitive), example: ['jpg', 'png'] | ![]() |
![]() |
All properties including the inherited ones can be listed via registeredPropertyNames
Method Summary
Public Methods | ||
public |
Returns the basename of the file path |
|
public |
Returns the dirname of the file path |
|
public |
Returns either the extension of the file path or an empty string in case the file path does not have an extension |
|
public |
Returns the file stats |
Protected Methods | ||
protected |
async _validation(at: null | number): Promise<*> Implements input's validations |
Inherited Summary
From class Input | ||
public static |
Creates an input instance. |
|
public static |
Registers a new input type to the available inputs |
|
public static |
registerProperty(inputClassOrRegisteredName: string | Input, name: string, initialValue: *) Registers a property for the input type (also available as |
|
public static |
registeredInput(name: string): Input Returns the input type based on the registration name |
|
public static |
Returns a list containing the names of the registered input types |
|
public static |
registeredPropertyNames(inputClassOrRegisteredName: string | Input): Array<string> Returns a list about all registered property names including the inherited ones for the input type |
|
protected static |
_decodeScalar(value: string): * Decodes the input value from the string representation (Input._encodeScalar) to the data type of the input. |
|
protected static |
_decodeVector(value: string): * Decodes a vector value from the string representation ({Input._encodeScalar & Input._encodeVector) to the data type of the input. |
|
protected static |
_encodeScalar(value: *): string Encodes the input value to a string representation that can be later decoded through Input._decode. |
|
protected static |
_encodeVector(values: Array<string>): string Encodes a vector value to a string representation that can be later decoded through Input._decodeVector. |
|
public |
assignProperty(name: string, value: *, loose: boolean) Sets a property to the input. |
|
public |
Returns the cache used by the input |
|
public |
Forces to flush the internal input cache |
|
public |
hasProperty(name: string): boolean Returns a boolean telling if the input property name is assigned to the input |
|
public |
Returns if the value of the input is empty. |
|
public |
isPropertyLocked(name: string): boolean Returns a boolean telling if the property is locked (Input.lockProperty) |
|
public |
Returns if the value of the input is required. |
|
public |
Returns if the input is serializable |
|
public |
Returns if the value of the input is a vector. |
|
public |
lockProperty(name: string, lock: boolean) Prevents a property value to be modified by Input.assignProperty |
|
public |
Returns the name of the input which is defined at construction time (inputs cannot be renamed) |
|
public |
parseValue(value: string, assignValue: boolean): * Decodes a value represented as string to the type that is compatible with the input. |
|
public |
Returns the property value for the input property name |
|
public |
propertyNames(): Array<string> Returns a list containing the property names assigned to the input |
|
public |
Returns a boolean telling if the input is in read-only mode. |
|
public |
async serializeValue(): Promise<string> This method should return a string representation about the current value in a way that can be recovered later through parseValue. |
|
public |
setReadOnly(enable: boolean) Changes the read-only state of the input. |
|
public |
setValue(value: *) Sets the value of the input |
|
public |
Sets the input value by avoiding the overhead that may occur when the same value is used across actions that have the input type, therefore this method avoids the re-computation by copying the caches and value associated with the source input to the current input. |
|
public |
Executes the input validations (_validation), in case of a failed validation then an exception of type ValidationFail is raised |
|
public |
value(): * Returns the value of the input |
|
public |
This method enforces the context of the value being queried. |
|
protected |
_getFromCache(name: string, at: null | number): * Auxiliary method used internally by the input implementations to get a value from the cache |
|
protected |
Auxiliary method used internally by input implementations to check if the key is under the cache |
|
protected |
_setToCache(name: string, value: *, at: null | number) Auxiliary method used internally by input implementations to set a value to the cache |
|
protected |
async _validation(at: null | number): Promise<*> Use this method to implement generic validations for your input implementation. |
From class BaseText | ||
protected static |
_decodeVector(value: string): * Decodes a vector value from the string representation (Input._encodeVector) to the data type of the input. |
|
protected static |
_encodeVector(values: Array<string>): string Encodes a vector value to a string representation that can be later decoded through Input._decodeVector. |
|
public |
Returns if the input is empty |
|
protected |
_validation(at: null | number): Promise<*> Implements input's validations |
Public Methods
public basename(at: null | number): string source
Returns the basename of the file path
const myInput = Input.createInput('myInput: filePath');
myInput.setValue('/tmp/file.jpg');
console.log(myInput.basename()); // 'file.jpg'
public dirname(at: null | number): string source
Returns the dirname of the file path
let myInput = Input.createInput('myInput: filePath');
myInput.setValue('/tmp/file.jpg');
console.log(myInput.dirname()); // tmp
public extension(at: null | number): string source
Returns either the extension of the file path or an empty string in case the file path does not have an extension
let myInput = Input.createInput('myInput: filePath');
myInput.setValue('/tmp/file.jpg');
console.log(myInput.extension()); // jpg
Protected Methods
protected async _validation(at: null | number): Promise<*> source
Implements input's validations