File

files/src/file_upload.ts

Description

This service is supposed to be declared as provider for a container with content style 'fileupload' and then injected into its constructor as a Self dependency.

Index

Methods
Accessors

Constructor

constructor(container: Container, session: BlueriqSession, uploadService: UploadService, eventHandler: SessionEventHandler, errorHandler: FunctionalErrorHandler, dispatcher: Dispatcher)
Parameters :
Name Type Optional
container Container No
session BlueriqSession No
uploadService UploadService No
eventHandler SessionEventHandler No
errorHandler FunctionalErrorHandler No
dispatcher Dispatcher No

Methods

getUploadDetails
getUploadDetails()

Returns an UploadDetails object which contains the URL to use for uploading with this container, additional headers to apply to the request and possibly multipart contents.

Returns : UploadDetails
handleFileUploadCompleted
handleFileUploadCompleted(response: UploadResponse)

When the files are uploaded, the runtime responds with events describing the page changes. Because the upload is triggered by the upload component, which does not understand these events, this function needs to be called to handle them appropriately.

This method should even be called for fault-responses. They may be recognized as functional errors and handled as such, or an exception is thrown to indicate that something went wrong.

Parameters :
Name Type Optional Description
response UploadResponse No

The response from the upload call.

Returns : void
toHumanReadableSize
toHumanReadableSize(sizeInBytes: number, precision: number)

Formats a size in bytes to a human readable text string.

e.g. 1048576 -> '1 MB'

Parameters :
Name Type Optional Default value Description
sizeInBytes number No

the size in bytes

precision number No 2

the number of digits after the fractional point (default 2)

Returns : string

a textual representation of the size

Accessors

allowedExtensions
getallowedExtensions()

Array containing the file extensions (without dot) that can be uploaded. If not defined, all file extensions are allowed.

Returns : [] | undefined
maxFileSize
getmaxFileSize()

Represents the maximum file size for a file to upload in bytes. If not defined, there is no limit. Note that when defined the limit applies to each file individually when uploading multiple files in one go.

Returns : number | undefined
multiple
getmultiple()

Returns whether this file upload container accepts multiple files.

Returns : boolean
uploadLabel
getuploadLabel()

Returns the text label (in the specified language), taking into account if this container can upload multiple files or not.

Returns : string
maxFileSizeDescription
getmaxFileSizeDescription()

Returns a text message to display regarding the max file size of a file to upload. If there is no maximum file size specified, an empty string is returned.

Returns : string
allowedExtensionsDescription
getallowedExtensionsDescription()

Returns a text message to display regarding the allowed extensions of a file to upload. If there are no restrictions, an empty string is returned.

Returns : string
uploadSucceededMessage
getuploadSucceededMessage()

Text message to display when an upload succeeded.

Returns : string
uploadFailedMessage
getuploadFailedMessage()

Text message to display when an upload failed.

Returns : string
extensionInvalidValidationMessage
getextensionInvalidValidationMessage()

Text message to display when an upload failed because of a file extension that is not allowed.

Returns : string
fileTooLargeValidationMessage
getfileTooLargeValidationMessage()

Text message to display when an upload failed because of the size of the file that is too large.

Returns : string

result-matching ""

    No results matching ""