Working With Panel Files
Overview
This article outlines how to work with files stored in panels (or other binary-type data) using the iMIS connector in Power Automate and Logic Apps. Learn how to work with file data in iMIS - extract file data from panels, and import files and file metadata into iMIS panels.
Technical Summary
Problem
iMIS stores files inside panels in an encoded XML document behind the scenes. This XML document contains four fields:
File
FileType
UploadedFileName
FileContentType
This document is incompatible with Power Automate, as the following diagrams demonstrate.
Shown above, when sending a file from iMIS to Power Automate, we can simply discard the extra information that Power Automate does not have inputs for.
However, when sending a file from Power Automate to iMIS, we don't have the required fields:
Solution
We must therefore wrap the fields required by iMIS (the file and its metadata) in an object:
Creating a File Wrapper
Follow these steps to create a file description wrapper object in your Power Automate flow.
This example will use a OneDrive file as the source file, which is an output of the action OneDrive for Business > Get File Content Using Path.
Add the Compose Action
First, add a step before your iMIS panel step and after you have retrieved your file contents.
Choose the Data Operations > Compose built-in action:
You should see a field called Inputs. In this input field, copy and paste the following JSON template code:
{
"File": "",
"FileName": "",
"MimeType": ""
}
Add File Data
To add the actual file contents, place your cursor in between the two quotes (""
), and then choose the "File contents" variable (or whichever variable contains your file data).
Add File Name
To add the file name, simply follow the same steps as above, placing your cursor between the two quotes and selecting the variable that contains your file name.
File Paths Accepted!
You may also supply a file path (a file name which contains some folders before it, delimited by /
or \
). The connector will automatically parse out a file path and determine the correct file name.
Examples:
ABC.pdf → ABC.pdf
/Documents/Scanned Files/Scan-2022-01-01.pdf → Scan-2022-01-01.pdf
C:\Users\Bob\Documents\Sample.csv → Sample.csv
/MyFile.xlsx → MyFile.xlsx
This allows you to feed in a file path directly from a cloud storage provider such as OneDrive or Google Drive without having to parse out the filename manually.
You can also type a filename manually between the quotes. Note that this means the filename will be the same each time the automation runs.
Add MIME Type
You must also supply a MIME Type, sometimes referred to as a Media Type or Media Header.
Please refer to the following table for a list of common MIME Types:
MIME Type | Corresponding File Types |
---|---|
application/vnd.openxmlformats-officedocument.wordprocessingml.document | DOCX |
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet | XLSX |
application/vnd.openxmlformats-officedocument.presentationml.presentation | PPTX |
application/pdf | |
application/xml | XML |
application/zip | ZIP |
text/plain | TXT, LOG |
text/csv | CSV |
text/html | HTM, HTML |
image/png | PNG, APNG |
image/jpeg | JPG, JPEG |
image/gif | GIF |
image/bmp | BMP |
video/mp4 | MP4 |
application/octet-stream | Any (see below) |
For additional MIME types, please refer to this MDN article.
Don't have or can't determine the MIME Type?
It's important to store the correct MIME Type with your file, so that iMIS knows how best to serve your content. (For example, if you specify that you have a PDF document, some browsers and mobile devices will display a preview instead of downloading the file).
However, in some contexts, you may not have the appropriate MIME Type. That's okay.
If you are unable to provide the MIME Type and you cannot enter a manual value because you'll be handling many different types of files with a particular automation, simply use the following "catch-all" MIME Type:
application/octet-stream
This instructs most browsers that this file should be downloaded, regardless of its content.
Using the Compose Action's Output
Once you have the three fields (File, File Name, and MIME Type), you can now use this "file object" inside of a "Create Panel" or "Update Panel" action.
Simply connect the "Output" variable from the Compose action into any "File" or "Binary" panel field.
You should always test your automations. In particular, verify that the file is written to the panel source successfully in iMIS, you are able to successfully download the file from the panel in iMIS, and that the file is not corrupt.