open_file
Opens a file from the filesystem and returns it as an Attachment instance. This is useful for loading files that need to be uploaded as attachments to target systems during data migration.
Syntax
open_file(file_path)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| file_path | string | Yes | The absolute path to the file to open. |
Returns
Type: Attachment
An Attachment instance with the file's content loaded, ready to be used in attachment upload operations.
Examples
Loading a file as an attachment:
open_file("/pb/data/documents/report.pdf")
Returns an Attachment instance containing the contents of report.pdf.
Loading a file using a dynamic path:
open_file(concatenate("/pb/data/attachments/", [file_name]))
Builds the file path from the record's file_name field and loads it as an attachment.
Notes
- The file path must be an absolute path within the container's filesystem.
- Unlike
read_file, this function returns an Attachment object rather than a raw string, making it suitable for binary files and attachment uploads. - If the file does not exist or cannot be read, an error will be raised.
- Files within the Precision Bridge data volume are typically located under the
/pbdirectory.
Comments
0 comments
Please sign in to leave a comment.