Skip to main content
Version: v5.0

IafFileContainer

Use the IafFileContainer API to manage file containers.

createContainer#

Creates a FileContainer class object.

ParameterRequiredTypeDescription
containerIdYesStringThe parent FileContainer id
containerInfoYesFileContainerPass a FileContainer object with the properties you want to define the your container.
ctxNoCtxContext storage that contains data, such as authorization token requirements, namespaces, or session storage.
Returns

FileContainer - The created FileContainer

Examples
const containerInfo = {  _name: "elem_warranty_files",  _description: "building_elements_warranty_files",  _shortName: "be_warranties",  _userType: "file_col"};
const createdContainer = await createContainer(parentContainer._id, containerInfo);

createFileItem#

Creates a file item.

ParameterRequiredTypeDescription
containerIdYesStringThe parent FileContainer's id
fileItemYesFileItemPass a FileItem object with the properties and values to define your file item.
ctxNoCtxContext storage that contains data, such as authorization token requirements, namespaces, or session storage.
Returns

FileItem - The created FileItem object

Examples
let testFileItem = await IafFileContainer.createFileItem(  parentContainer._id,   {_description: "test_file"});

createRootContainer#

Creates a root FileContainer.

ParameterRequiredTypeDescription
containerInfoYesFileContainerPass a FileContainer object with the properties you want to define the your root container.
ctxNoCtxContext storage that contains data, such as authorization token requirements, namespaces, or session storage.
Returns

FileContainer - The created FileContainer object

Examples
const containerInfo = {  _name: "elem_warranty_folder",};
const rootContainer = await createRootContainer(containerInfo, ctx);

deleteFileItem#

Deletes a FileItem.

ParameterRequiredTypeDescription
containerIdYesStringThe parent FileContainer or folder's id
fileItemIdYesStringThe FileItem's id
ctxNoCtxContext storage that contains data, such as authorization token requirements, namespaces, or session storage.
Returns

Promise<{itemResult}> -

Examples
const deletedFile = await IafFileContainer.deleteFileItem(container._id, fileItem._id);

getChildContainers#

Gets the child FileContainer objects of a parent FileContainer.

ParameterRequiredTypeDescription
containerIdYesStringThe parent FileContainer's id
queryNoJSONTo filter your search, pass a simple query object.
ctxNoCtxContext storage that contains data, such as authorization token requirements, namespaces, or session storage.
optionsNoNamedUserItemCriteriaOptionsPass a NamedUserItemCriteriaOptions object with your response options, such as projection, sort, page size and offset options.
Returns

Array<FileContainer> - The child containers that match your query

Examples
let childContainers = await IafFile.getChildContainers(  currentFolder._id,  undefined,  ctx,  undefined);

getContainer#

Gets a FileContainer when you pass its id.

ParameterRequiredTypeDescription
containerIdYesStringThe FileContainer's id
ctxNoCtxContext storage that contains data, such as authorization token requirements, namespaces, or session storage.
Returns

FileContainer - The FileContainer object you want

Examples
const container = await getContainer(parentContainer._id);

getFileItem#

Gets a FileItem from a FileCollection.

ParameterRequiredTypeDescription
containerIdYesStringThe FileContainer or folder's id
fileItemIdYesStringThe FileItem's id
ctxNoCtxContext storage that contains data, such as authorization token requirements, namespaces, or session storage.
Returns

FileItem - The FileItem object

Examples
const file = await IafFileContainer.getFileItem(container._id, fileItem._id);

getFileItems#

Gets FileItem objects in a container.

ParameterRequiredTypeDescription
containerIdYesStringThe FileContainer or folder's id
queryYesJSONTo filter your response, pass a simple query.
ctxNoCtxContext storage that contains data, such as authorization token requirements, namespaces, or session storage.
optionsYesRelatedItemCriteriaOptionsoptional params such as _pageSize and _offset
Returns

any - Array - Array of FileItem objects

Examples
const fileItems = await IafFileContainer.getFileItems(container._id, undefined, ctx, undefined);

updateFileItem#

Updates a FileItem with the updated properties and values you pass.

ParameterRequiredTypeDescription
containerIdYesStringPass the FileContainer or folder's id
fileItemIdYesStringThe FileItem's id
fileItemYesFileItemPass a FileItem object with your updated properties and values.
ctxNoCtxContext storage that contains data, such as authorization token requirements, namespaces, or session storage.
Returns

FileItem - The updated FileItem object

Examples
const fileItemDesc = {"_description": "updated_test_file"};
const updatedFile = await IafFileContainer.updateFileItem(container._id, file._id, fileItemDesc);

uploadFile#

Uploads a file to a FileContainer as a FileItem class object.

ParameterRequiredTypeDescription
containerIdYesStringThe file container's id.
fileYesReadStreamPass a ReadStream object.
tagsNoArray<String>Pass any metadata tags you want to add to the file in an array.
ctxNoCtxContext storage that contains data, such as authorization token requirements, namespaces, or session storage.
optionsYesFileOptionsPass a FileOptions object with your file options as properties, such as "headers", and "filename".
Returns

FileItem - The created FileItem

Examples
await IafFileContainer.uploadFile(currentContainer._id, file);