Delivered Record Definitions

The following table summarizes the delivered record definitions for use in a file attachment application:

Record Example Description

FILE_ATTDET_SBR

MYAPP_ATT_CNTNT

Insert this subrecord in any record definition for target tables that will store attached files. Do not add other fields to this record.

FILE_ATTACH_SBR

MYAPP_ATT_REF

Insert this subrecord in any application-specific record for tables that will store references to attached files. The fields in this subrecord store the system file name and the user file name.

FILE_ATTACH_WRK

MYAPP_ATT_WRK

Clone this derived/work record to create your own application-specific derived/work record. In your application-specific derived/work record, you can modify your copy of the delivered sample code to meet your file attachment requirements and manage your file reference table (or tables).

FILE_ATTDET_SBR Subrecord

To use a database table as a storage location, you must create an application-specific record definition associated with the target table that will receive the attachments. You must include the FILE_ATTDET_SBR subrecord in your application-specific record, and it can contain no additional fields.

The FILE_ATTDET_SBR subrecord has the following fields:

Field Description

ATTACHSYSFILENAME

The system file name, which must be unique to the storage location in order to avoid unintended file overwrites. Furthermore, if the file reference table to be used will contain references to file stored at more than one storage location, then the system file name must also be unique to that table.

The value of the ATTACHSYSFILENAME field in the corresponding row of the file reference table must be identical to this value.

ATTACHSYSFILENAME is a 128-character field.

FILE_SEQ

The file sequence number (to support file chunking).

VERSION

Version number.

FILE_SIZE

The physical size of the file chunk.

LASTUPDDTTM

Last update date and time.

LASTUPDOPRID

The user ID of the last user to update the attachment.

FILE_DATA

The data of the file chunk.

PeopleTools maintains the values in this table. Therefore, do not reuse the fields in this table to store incomplete or nonstandard versions of the file name or other data.

FILE_ATTACH_SBR Subrecord

You must insert the FILE_ATTACH_SBR subrecord in the application-specific record definition to be associated with the table that will store references to the attached files. The fields in this subrecord store the system file name and the user file name.

The FILE_ATTACH_SBR subrecord contains the following fields:

Field Description

ATTACHSYSFILENAME

The system file name (the name of the file as it exists at the storage location).

Among other things, this means that if the file is stored in a database table, then the value in this field must be identical to the value of the ATTACHSYSFILENAME field in the rows that correspond to the file chunks in the database table.

ATTACHSYSFILENAME is a 128-character field.

ATTACHUSERFILE

The user file name (the name that the end user associates with the file).

ATTACHUSERFILE is a 64-character field.

Your application must populate these fields with the system file name, user file name, and any information about the file that will be needed for later use.

See Managing Entries in File Reference Tables.

FILE_ATTACH_WRK Derived/Work Record

The FILE_ATTACH_WRK derived/work record provides sample PeopleCode programs that demonstrate how to use the file attachment PeopleCode built-in functions. Clone this derived/work record so that you can customize the programs to suit your application's needs.

The FILE_ATTACH_WRK derived/work record contains the following fields:

Field Description

ATTACHADD

Contains a PeopleCode program used for uploading an attachment from an end-user machine to the specified storage location (via the AddAttachment built-in function).

ATTACHDET

Contains a PeopleCode program used for downloading an attachment from the specified storage location to be saved on the end-user machine (via the DetachAttachment built-in function).

ATTACHDELETE

Contains a PeopleCode program used for deleting an attachment from the specified storage location (via the DeleteAttachment built-in function).

ATTACHUTIL

Contains a user-defined PeopleCode function that can be called to determine (by file name extension) whether the attachment operation will be permitted on a file. In this function, an array of file name extensions identifies which types of files will be regarded as impermissible.

Note: The sample PeopleCode programs included in the FILE_ATTACH_WRK derived/work record invoke this user-defined PeopleCode function.

ATTACHVIEW

Contains a PeopleCode program used for downloading an attachment from the specified storage location to be viewed on the end-user machine (via the ViewAttachment built-in function).

The PeopleTools Test Utilities page demonstrates a sample application that makes use of the PeopleCode programs in the FILE_ATTACH_WRK derived/work record.

See Using the PeopleTools Test Utilities Page.