File Items
Oftentimes, there is a need to use a file in the File Service as if it existed in the Item Service. Perhaps you have an Operations Manual pdf that you'd like to relate to the Assets the manual applies to. Or perhaps you'd like to add additional data to a file that the File Service doesn't support.
In these instances, and more, you'd want to use a file item to represent the file in the item service.
In this lesson you will learn about FileContainers and FileItems in the Item Service and how they relate to folders and files in the File Service.
File Items: Where File Service Meets Item Service
FileItems
A FileItem represents or mirrors a file in the File Service. Since the FileItem is a special type of item in the Item Service, and essentially schema-less, you can use a FileItem to add information and relationships to a file which you can't add in the File Service. Each FileItem contains the id of the file it mirrors in the File Service along with other version and version id information.
Why use a file item?
Perhaps you have Assets, and those assets have files or documents that relate to them. Things like operations manuals, warranty documents, or even testing and installation forms. You can upload those files to the File Service and take advantage of all the benefits of versioning and tagging and organizing the files, but you can't then relate those files to assets using the Item Service's relationships. That's where a FileItem comes in. With a FileItem mirroring the file in the File Service, you can track additional properties for the file. Things like the supplier's name and the date the file was received from the supplier. But you can then also take advantage of the Item Service relations to then relate the FileItem to the asset; making finding files related to assets or assets related to files very easy.
FileContainers
If a FileItem is the Item Service mirror of a file in the File Service, then a FileContainer is the Item Service mirror of a folder in the File Service. One important thing to know? FileContainers are actually a specialized type of NamedUserCollection called a NamedFileCollection.
Using FileItems and FileContainers
The IafFile library in the PlatformApi module makes it easy to manage your files and folders in relation to your FileItems and FileContainers.
When using IafFile to upload files, you can upload a file to a folder in the File Service, and create or update a FileItem in a FileContainer all at the same time.
In the next steps of this lesson you see firsthand how FileItems and FileContainers work.
Hands On
- Download the B07 - File Items.zip file and extract the files
- Open the .mjs file in your IDE
- Follow the steps in the file