core/common/files.service.ts
Properties |
|
Methods |
constructor(systemOptionsService: SystemOptionsService, inventoryBinaryService: InventoryBinaryService)
|
|||||||||
Parameters :
|
checkMaxLength | ||||||||
checkMaxLength(files: FileList)
|
||||||||
Checks if each file has a valid filename length.
Parameters :
Returns :
boolean
Returns true if each file has a valid filename length. |
Async download | ||||||||
download(binary: IManagedObjectBinary)
|
||||||||
Allows to download a file (opens the browser download prompt).
Parameters :
Returns :
any
|
extractFileExtensions | ||||||||
extractFileExtensions(str: string)
|
||||||||
Extracts a list of file extensions from a string. Can accept generic file types check: GENERIC_FILE_TYPE. Accepted string format:
Parameters :
Returns :
string[]
Returns a list of the file extensions. |
getFileExtension | ||||||||
getFileExtension(file: File)
|
||||||||
Extracts the file extension.
Parameters :
Returns :
string | undefined
Returns the file extension or undefined if the file has no extension. |
getFileExtensions |
getFileExtensions()
|
List of file extensions.
Returns :
string[]
Returns list of file extensions. |
getGenericFileTypes |
getGenericFileTypes()
|
The list of generic file types.
Returns :
GENERIC_FILE_TYPE[]
Returns the list of generic file types. |
haveValidExtensions | ||||||||||||
haveValidExtensions(files: FileList | File, accept: string)
|
||||||||||||
Checks whether files have allowed extensions. If the accept parameter is not specified, all extensions are accepted.
Parameters :
Returns :
boolean
Returns true if each file has allowed extension. |
Async haveValidSizes | ||||||||
haveValidSizes(files: FileList)
|
||||||||
Checks if files have valid size.
Parameters :
Returns :
Promise<boolean>
Returns true if each file has the correct size. |
Async loadBytesSizeLimit |
loadBytesSizeLimit()
|
Checks the system file size limit, if not available returns the default value. Default limit: DEFAULT_BYTES_LIMIT
Returns :
Promise<number>
Returns promise with the limit value. |
size | ||||||||
size(file: File | IManagedObjectBinary)
|
||||||||
Checks the size of the file
Parameters :
Returns :
number
Returns size of the file in bytes. |
toBase64 | ||||||||
toBase64(file: File)
|
||||||||
Converts a file to a base64 image string.
Parameters :
Returns :
any
The image string in base64 format. |
Readonly DEFAULT_BYTES_LIMIT |
Type : number
|
Default value : 52428800
|
Readonly FILENAME_MAX_LENGTH |
Type : number
|
Default value : 128
|
fileTypeExtensionsMap |
Type : literal type
|
Default value : {
[GENERIC_FILE_TYPE.ARCHIVE]: {
exts: ['7z', 'apk', 'cab', 'gz', 'iso', 'jar', 'rar', 'tar', 'zip']
},
[GENERIC_FILE_TYPE.AUDIO]: {
exts: ['3gp', 'aiff', 'aac', 'amr', 'm4a', 'm4p', 'mp3', 'oga', 'ogg', 'raw', 'wav', 'wma']
},
[GENERIC_FILE_TYPE.CODE]: {
exts: ['aspx', 'exe', 'htm', 'html', 'jad', 'js', 'json', 'jsp', 'php', 'xml']
},
[GENERIC_FILE_TYPE.EXCEL]: {
exts: ['xls', 'xlsx']
},
[GENERIC_FILE_TYPE.IMAGE]: {
exts: ['bmp', 'gif', 'jpeg', 'jpg', 'png', 'tiff', 'svg', 'ico']
},
[GENERIC_FILE_TYPE.PDF]: {
exts: ['pdf']
},
[GENERIC_FILE_TYPE.POWERPOINT]: {
exts: ['ppt', 'pptx']
},
[GENERIC_FILE_TYPE.TEXT]: {
exts: ['txt']
},
[GENERIC_FILE_TYPE.VIDEO]: {
exts: ['asf', 'avi', 'flv', 'mov', 'mp4', 'ogv', 'qt', 'rm', 'rmvb', 'wmv', '3gp']
},
[GENERIC_FILE_TYPE.WORD]: {
exts: ['doc', 'docx']
},
[GENERIC_FILE_TYPE.EPL]: {
exts: ['mon']
}
}
|