Give us feedback
client-file-handler
Reactive icon

Client File Handler

version 0.0.2 (Compatible with OutSystems 11)
Uploaded on 16 October 2022 by 
5.0
 (1 rating)
client-file-handler

Client File Handler

Documentation
0.0.2

File Chunker Control

The control is an upload type input ( same user experience as the Outsystems control ) that instead of producing a single binary, produces and transmits via "OnChunksProcessDone" event the file divided into chunks.
The control has a main placeholder to completely change the graphics of the component.


Chunker Delegate Progress bar

The chunker uploader controls in "Delegate" mode (progress bar & circle ) delegate the upload of the individual chunk to an action (client,server,service) exposed by the web application.
To perform the upload, simply prepare an action ,which handles the insertion of the binary data into the db or other storage, and use it within the "OnDelegateUploadChunkAction Event".
The control triggers the event for each chunk in the "FileChunks" parameter.



0.0.1

WORK IN PROGRESS

Overview

eSpace Name

FileClientHandler_Lib

Description

A collection of block and client actions to handle files.


Implementation


UI Flows


FileStream Blocks


StreamDownload            

Listener block to download file from an http endpoint.

Parameters

Name

Description

Type

Mandatory

TargetUrl

The url to fetch the resources.

Text

YES

FileName

The target file name with extension.

Text

YES

AutoDownloadFile

Indicate if the widget must trasmit and start download process to the browser.

Boolean

YES

AutoStartStreamProcess

Indicate if the widget must start the stream reading process.

Boolean

YES

FetchRequestSettings

Fetch settings.

StreamFetch RequestConfig

NO


Events

OnComplete

Event triggered when the stream process complete.

Mandatory: NO

Name

Description

Data Type

StreamSize

The total stream size for the requested file.

Long Integer

StreamProcessedSize

The total parsed stream for the requested file.

Long Integer

StreamReadProgress

The percentage that indicate how much stream was parsed.

Decimal

DownloadUrl

The download url produced by the streamer. Its start always with blob:......

Text



OnError

Event triggered when an error occurs.

Mandatory: NO

Name

Description

Data Type

ErrorMessage

The description of error.

Text



OnProgress

Event triggered when the stream process progess.

Mandatory: NO

Name

Description

Data Type

StreamSize

The total stream size for the requested file.

Long Integer

StreamProcessedSize

The total parsed stream for the requested file.

Long Integer

StreamReadProgress

The percentage that indicate how much stream was parsed.

Decimal



OnStart

Event triggered when the stream process start.

Mandatory: NO

Name

Description

Data Type

StreamSize

The total stream size for the requested file.

Long Integer

StreamProcessedSize

The total parsed stream for the requested file.

Long Integer

StreamReadProgress

The percentage that indicate how much stream was parsed.

Decimal



FileChunker Blocks


UploadChunker

Upload block that split file in chunks.

Parameters

Name

Description

Type

Mandatory

Accepts

A string with allowed mime types separated by "," ( ex: image/png, image/jpeg,....)

Text

YES

ChunkSizeInKB

The size of chunks to produce.

Long Integer

YES

MaxFileSizeInKB

The max file size, if the selected file size is greater the control send the event OnSizeExceed.

Long Integer

YES

IsMandatory

Check if the control is mandatory

Boolean

YES

StartChunkProcessWhenFileChange

Indicate if the chunk generation process must start where a file is selected, otherwise you can control the process with client action "StartFileChunkProcess".

Boolean

YES

AllowDrop

Indicate if the block must handle file drop.

Boolean

YES


Events

OnChunkProcessStart

Event triggered when the chunk process starts.

Mandatory: NO

 

OnChunksProcessDone

Event triggered when all chunks are generated.

Mandatory: YES

Parameters

Name

Description

Data Type

FileChunks

The list of chunks

FileChunk List

 

OnError

Event triggered when an error occurs in the chunk process or in the file processing.

Mandatory: NO

Parameters

Name

Description

Data Type

ErrorMessage

The description of error.

Text

 

 

 

OnFileChange

Event triggered when a file is selected

Mandatory: YES

Parameters

Name

Description

Data Type

FileName

The selected filename.

Text

FileMimeType

The selected file mime types.

Text

FileSizeInKB

The selected file size in KB

Long integer

FileSizeInMB

The selected file size in MB

Decimal

FileSizeInGB

The selected file size in GB

Decimal

 

OnFileSelectedSizeExceed

Event triggered when the selected file size is greater than the MaxFileSizeInKB parameter.

Mandatory: NO

Parameters

Name

Description

Data Type

FileSizeKB

The selected file size in KB

Long Integer

MaxFileSizeKB

The max allowed size in KB

Long Integer

 

OnWrongFileTypeSelected

Event triggered when the selected file mime type is not contained in the Accepts parameter.

Mandatory: NO

Parameters

Name

Description

Data Type

FileType

The selected file mime type

Text

AllowedFileTypes

The allowed file types

Text


Structures

DictionaryBinaryValues

Simulate Dictionary<int,binary>

Attributes

Attribute

Description

Type

Mandatory

Index

The index value.

Integer

YES

Binary

The binary value

Binary Data

YES


DictionaryStrings

Simulate Dictionary<string,string>

Attributes

Attribute

Description

Type

Mandatory

Key

The key

Text

YES

Value

The value

Text

YES

 

 

 

KeyValuesString

Simulate Dictionary<string,List<string>>

Attributes

Attribute

Description

Type

Mandatory

Key

The key

Text

YES

Values

The list of values

Text

YES

 

StreamFetchRequestConfig

Configuration for the fetch request

Attributes

Attribute

Description

Type

Mandatory

Method

The request method, e.g., GET, POST. Note that the Origin header is not set on Fetch requests with a method of HEAD or GET.

Text

NO

Mode

The mode you want to use for the request, e.g., cors, no-cors, or same-origin.

Text

NO

Cache

A string indicating how the request will interact with the browser's HTTP cache. The possible values, default, no-store, reload, no-cache, force-cache, and only-if-cached, are documented in the article for the cache property of the Request object.

Text

NO

Credentials

Controls what browsers do with credentials (cookies, HTTP authentication entries, and TLS client certificates). Must be one of the following strings:


omit

Tells browsers to exclude credentials from the request, and ignore any credentials sent back in the response (e.g., any Set-Cookie header).


same-origin

Tells browsers to include credentials with requests to same-origin URLs, and use any credentials sent back in responses from same-origin URLs. This is the default value.


include

Tells browsers to include credentials in both same- and cross-origin requests, and always use any credentials sent back in responses.

Text

NO

Headers

Any headers you want to add to your request, contained within a Headers object or an object literal with String values

DictionaryStrings List

NO

Redirect

How to handle a redirect response:


follow: Automatically follow redirects. Unless otherwise stated the redirect mode is set to follow.

error: Abort with an error if a redirect occurs.

manual: Caller intends to process the response in another context. See WHATWG fetch standard for more information.

Text

NO

ReferrerPolicy

Specifies the referrer policy to use for the request. May be one of no-referrer, no-referrer-when-downgrade, same-origin, origin, strict-origin, origin-when-cross-origin, strict-origin-when-cross-origin, or unsafe-url.

Text

NO


FileChunk

Structure to handle chunks.

Attributes

Attribute

Description

Type

Mandatory

Binary

Binary data

Binary Data

YES

Sequence

Integer that indicates the sequence of chunks

Integer

YES

Range

The content range of the single chunk

Text

YES


FilePickerOption

Structure to handle the pickers' options.

Attribute

Description

Type

Mandatory

Description

The description to use in the picker ( Text File, Images,Videos, etc...)

Text

YES

Accept

The allowed mime types ( text/...., application/...)

Text List

YES


Actions

Client Actions

StartFileChunkProcess (Folder Chunker)

Start the UploadChunker chunk generation process.

Input parameters

Name

Description

DataType

Mandatory

SingleFileChunkerId

The id of UploadChunker block

Text

Yes


CancelProcess (Folder StreamDownloader)

Cancel stream download process.

Input parameters

Name

Description

DataType

Mandatory

StreamDownloadId

The id of the stream download widget

Text

Yes

DownloadFile (Folder StreamDownloader)

Download the file.

Input parameters

Name

Description

DataType

Mandatory

StreamDownloadId

The id of the stream download widget

Text

Yes


StartProcess (Folder StreamDownloader)

Start stream download process.

Input parameters

Name

Description

DataType

Mandatory

StreamDownloadId

The id of the stream download widget

Text

Yes


ArePickersSupported (Folder Pickers)

Check if file pickers are supported.

At the moment Y2022 only Edge,Chrome,Opera for desktop support these features.

Output parameters

Name

Description

DataType

IsSelectFileSupported

Indicate if file picker is supported

Boolean

IsSelectFolderSupported

Indicate if folder picker is supported

Boolean

IsSaveFileSupported

Indicate if save file picker is supported

Boolean


SaveFile (Folder Pickers)

Save the file with the name and location specificied by user through a save dialog.

Input parameters

Name

Description

DataType

Mandatory

SuggestedFilename

The suggested file name to show in the save dialog

Text

Yes

Type

The mime type of the file

FilePickerOption

Yes

Binary

The binary data of the file

Binary Data

Yes

ExcludeAllOption

Bool to exclude All File ( *.* ) from the save dialog

Boolean

Yes


SaveFileChunks (Folder Pickers)

Save the file with the name and location specificied by user through a save dialog.

Input parameters

Name

Description

DataType

Mandatory

SuggestedFilename

The suggested file name to show in the save dialog

Text

Yes

Type

The mime type of the file

FilePickerOption

Yes

FileChunks

A list of chunks to assemble and save.

FileChunk List

Yes

ExcludeAllOption

Bool to exclude All File ( *.* ) from the save dialog

Boolean

Yes


SelectFile (Folder Pickers)

Allow user to select a file without an input[type=file] or an upload block

Input parameters

Name

Description

DataType

Mandatory

AllowMultiple

WARNING WIP!!!!!!!!!!!              

Boolean

Yes

ExcludeAllOption

Bool to exclude All File ( *.* ) from the save dialog

Boolean

Yes

Types

The mime types allowed.

FilePickerOption List        


Yes

 

Output parameters

Name

Description

DataType

Filename

The selected file's name.

Text

Binary

The file binary

Binary Data


SelectFileChunks (Folder Pickers)

Allow user to select a file without an input[type=file] or an upload block. This action split the file in chunks.

Input parameters

Name

Description

DataType

Mandatory

AllowMultiple

WARNING WIP!!!!!!!!!!!              

Boolean

Yes

ExcludeAllOption

Bool to exclude All File ( *.* ) from the save dialog

Boolean

Yes

ChunkSizeKB

The size of the chunks to produce.

Long Integer     

Yes

Types

The mime types allowed.

FilePickerOption List        


Yes


Output parameters

Name

Description

DataType

Filename

The selected file's name.

Text

Binary

The chunk list

FileChunk List






DownloadFileByChunks (Folder Utilities)

Merge chunks and download the file.

Input parameters

Name

Description

DataType

Filename

The selected file's name.

Text

FileChunks

The list of chunks

FileChunk List


FromBinaryToChunks (Folder Utilities)

Split a binary into chunks.

Input parameters

Name

Description

DataType

Mandatory

BinaryData

WARNING WIP!!!!!!!!!!!              

Boolean

Yes

ChunkSizeKB

The size of the chunks to produce.

Long Integer              

Yes

 

Output parameters

Name

Description

DataType

Chunks

The list of chunks

FileChunk List


FromChunksToBinary (Folder Utilities)

Merge a list of chunks into single binary.

Input parameters

Name

Description

DataType

Mandatory

FileChunks

The list of chunks

FileChunk List              

Yes


Output parameters

Name

Description

DataType

Binary

The produced binary.

Binary Data


FromGBtoKB (Folder Utilities)

Convert GB To KB

Input parameters

Name

Description

DataType

Mandatory

GB

The gb decimal value

Decimal

Yes


Output parameters

Name

Description

DataType

KB

The size expressed in KB

Long Integer


FromMBtoKB (Folder Utilities)

Convert MB To KB

Input parameters

Name

Description

DataType

Mandatory

MB

The mb decimal value

Decimal

Yes


Output parameters

Name

Description

DataType

KB

The size expressed in KB

Long Integer