Files
Updated on Aug 24, 2023 4 minutes to readDownload
Syntax:
E8App.$files.download(<id>, <params>)
Description:
Initiates file download on a client’s device.
Parameters:
<id> - required
Type: String
File Id.
<params> - optional
Type: Object
File download parameters.
{ basename: <string> filename with file extension,filename: <string> filename without file extension,
inline: <boolean> True means file content will be displayed in the browser, False - file content or file download will open in the same tab,
newTab: <boolean> True specifies file content or file download will open in a new tab, False - file content or file download will open in the same tab }
Returned value:
Void.
E8App.$files.download('99c83c95-a178-43f1-a03a-fa2c1beab6ce', { inline: true, newTab: true });
Download Base64
Syntax:
E8App.$files.downloadBase64(<id>)
Description:
Returns a file encoded to Base64 format.
Parameters:
<id> - required
Type: String
File Id.
Returned value:
The promise resolves to string.
Type: Object
E8App.$files.downloadBase64('99c83c95-a178-43f1-a03a-fa2c1beab6ce');
Get download URL
Syntax:
E8App.$files.getDownloadUrl(<id>, <schema>, <params>)
Description:
Returns a link to download the file.
Parameters:
<id> - required
Type: String
File Id.
<schema> - optional (default = false)
Type: Boolean
This parameter describes the type of the desired link: True - absolute link is returned, False - relative link is returned.
<params> - optional
Type: Object
File download parameters.
{ basename: <string> filename with file extension,filename: <string> filename without file extension,
inline: <boolean> True means file content will be displayed in the browser, False - file content or file download will open in the same tab }
Returned value:
The promise resolves to string (file URL).
Type: Object
E8App.$files.getDownloadUrl('77c83c95-a161-43f1-a03a-fa2c1bngb6ce', { inline: true });
Get file info
Syntax:
E8App.$files.getInfo(<id>)
Description:
Gets file information.
Parameters:
<id> - required
Type: String
File Id.
Returned value:
The promise resolves to the object representing file parameters.
Type: Object
{appId: <string>, id: <string>, name: <string>, text: <string>, extension: <string>, size: <number>, mimeType: <string>, isImage: <Boolean>, isVideo: <Boolean>, isPreviewSupported: <Boolean>, isPublic: <Boolean>}
E8App.$files.getInfo('99c83c95-a178-43f1-a03a-fa2c1beab6ce', { inline: true });
Get thumbnail URL
Syntax:
E8App.$files.getthumbnailUrl(<id>, <size>, <schema>, <params>)
Description:
Returns the URL of a thumbnail.
Parameters:
<id> - required
Type: String
File Id.
<size> - optional
Type: Number
Desired size of a thumbnail in px (determines maximum dimension if the image ratio should be retained).
<schema> - optional (default = false)
Type: Boolean
This parameter describes the type of the desired link: True - absolute link is returned, False - relative link is returned.
<params> - optional
Type: Object
File download parameters.
{keepAspectRatio: <boolean>}
Returned value:
The promise resolves to string (file URL).
Type: Object
E8App.$files.getThumbnailUrl('77c83c95-a161-43f1-a03a-fa2c1bngb6ce', 100, true, { keepAspectRatio: true });
Make file private
Syntax:
E8App.$files.makePrivate(<id>)
Description:
Makes file unavailable for viewing by not logged-in users.
Parameters:
<id> - required
Type: String
File Id.
Returned value:
The promise resolves to void.
Type: Object
E8App.$files.makePrivate('77c83c95-a161-43f1-a03a-fa2c1bngb6ce');
Make file public
Syntax:
E8App.$files.makePublic(<id>, <params>)
Description:
Makes file available for all users (including not logged-in ones).
Parameters:
<id> - required
Type: String
File Id.
<params> - optional
Type: Object
Public file path.
{dir: <string> file path }
Returned value:
The promise resolves to void.
Type: Object
E8App.$files.makePublic('77c83c95-a161-43f1-a03a-fa2c1bngb6ce');
File preview
Syntax:
E8App.$files.preview(<id>, <params>)
Description:
Initiates file preview.
Parameters:
<id> - required
Type: String
File Id.
<params> - optional
Type: Object
File preview settings.
{ disableDownload: <boolean> disables file download,disablePrint: <boolean> makes printing the file inaccessible for a user,
disableSend: <boolean> disables send button,
disableShare: <boolean> disables share button }
Returned value:
The promise resolves to <boolean>. The value depends on whether the file preview succeeded or failed.
Type: Object
E8App.$files.preview('77c83c95-a161-43f1-a03a-fa2c1bngb6ce', {disableDownload: true, disablePrint: true, disableSend: true, disableShare: false});
File preview/download
Syntax:
E8App.$files.previewOrDownload(<id>, <params>)
Description:
Initiates file preview in modal, if failed – file download starts.
Parameters:
<id> - required
Type: String
File Id.
<params> - optional
Type: Object
File preview/download settings.
{ basename: <string> filename with file extension,disableDownload: <boolean> disables file download,
disablePrint: <boolean> makes printing the file inaccessible for a user,
disableSend: <boolean> disables send button,
disableShare: <boolean> disables share button
inline: <boolean> True means file content will be displayed in the browser, False - file content or file download will open in the same tab,
newTab: <boolean> True specifies file content or file download will open in a new tab, False - file content or file download will open in the same tab }
Returned value:
The promise resolves to <boolean>. The value depends on whether the file preview (or download if preview failed) succeeded or failed.
Type: Object
E8App.$files.preview('77c83c95-a161-43f1-a03a-fa2c1bngb6ce', {basename: 'certificate.pdf', disableDownload: false, disablePrint: false, disableSend: false, disableShare: false, inline: true, newTab: true});
File upload
Syntax:
E8App.$files.upload(<ownerScriptAlias>, <attrScriptAlias>)
Description:
Initiates file upload on a client’s device.
Parameters:
<ownerScriptAlias> - required
Type: String
Script alias of the list object to which the file will be attached.
<attrScriptAlias> - required
Type: String
Script alias of the list object to which the file will be attached.
Returned value:
The promise resolves and produces the object representing file information.
Type: Object
E8App.$files.upload('lstGoods', 'certificate');
File upload B64
Syntax:
E8App.$files.uploadBase64(<upload options>)
Description:
Starts uploading a file encoded to Base64 format.
Parameters:
<upload options> - required
Type: Object
File upload options.
fileName: <string> filename without file extension,
attrScriptAlias: <string> script alias of the list object attribute,
ownerScriptAlias: <string> script alias of the list object to which the file will be attached,
progressCallback: <function> callback indicates upload progress }
Returned value:
The promise resolves and produces an object representing file information.
Type: Object
E8App.$files.uploadBase64({'base64 string...', 'certificate_1', 'certificate', 'lstGoods', (e)=>{console.log(e)});
File upload B64
Syntax:
E8App.$files.uploadBase64(<ownerScriptAlias>, <attrScriptAlias>, <data>, <progressCallback>)
Description:
Starts uploading a file encoded to Base64 format.
Parameters:
<ownerScriptAlias> - required
Type: String
Script alias of the list object to which the file will be attached.
<attrScriptAlias> - required
Type: String
Script alias of the list object attribute.
<data> - required
Type: Object
File upload options.
{ base64str: <string> file encoded to Base64 format,basename: <string> filename with file extension }
<progressCallback> - optional
Type: Function
Callback indicates upload progress.
Returned value:
The promise resolves and produces an object representing file information.
Type: Object
E8App.$files.uploadBase64('lstGoods', 'certificate', {'base64 string...', 'certificate_2.pdf'}, (e)=>{console.log(e)})