getFileContentById

getFileContentById(options)

Method Description

This function allows you to get a file from an external file storage location and returns its contents in Base 64 encoding. 

Returns

Returns | DirectoryItem (see below)

Supported Script Types

SuiteScript 2.1
Server-side Scripts: User Event, Suitelet, RESTlet, Map/Reduce, Scheduled, Workflow Action

Limitations

File size capacity is limited to files 10MB or smaller

Module

b4cd-file-api-lib.js
See notes on how to load this module: FileSync API for SuiteScript

Since

FileSync 0.5.0

Parameters

Note: The options parameter is a JavaScript object.

ParameterTypeRequiredDescriptionSince
options.fileUniqueId
string


required

The unique ID of the file for which the content is being requested. This value is generally retrieved by making a call to the getRecordFolderContents method.0.5.0

options.recordTypeConfigId

integer


required

Internal ID of the FileSync Record Type Configuration record (customrecord_b4cd_record_type_config).

* Either the recordTypeConfigId or the connectionId can be provided. At least one of them is required.
0.5.0

Returns

PropertyTypeDescriptionSince
DirectoryItem.name

string

The file or folder name

0.5.0

DirectoryItem.uniqueId
stringThe unique ID of the file or folder as assigned by the file hosting service. 0.5.0
DirectoryItem.type
stringPossible Values: "file", "folder"0.5.0
DirectoryItem.fileSize
integerFile size in bytes.0.5.0
DirectoryItem.apiUri
stringThe URI used to access the file or folder via the API. 0.5.0
DirectoryItem.filePath
stringThe relative file or folder path on the file hosting service starting from the base directory. 0.5.0
DirectoryItem.uri
stringThe user-navigable URI for the folder or file on the file hosting platform. This can be used to construct hyperlinks for users to reach the file or folder externally. 0.5.0
DirectoryItem.fileContent

stringfile contents as encoded Base64 content0.5.0

Errors

Error Code
Details
MISSING_REQD_ARGUMENT

A required argument is missing or undefined.

Example Usage

var params = {
             'fileUniqueId': "5e433228-d3d6-4452-bc37-d2f8867dde29",
             'recordTypeConfigId':35
           }
var content = fileapi.getFileContentById(params)

Was this article helpful?