Attachment Fields

Attachment Fields

Attachment fields are for uploading files to your instance’s Document Library. When uploaded, the file is linked to the entry’s attachment field, and each field can only be linked to one file at a time. A file inherits its scope from the object definition (i.e., company or site). Once attached, you can view an object entry to download the file or remove it from the field. Beginning with 7.4 U45/GA45, you can also download entry attachments from the object’s application page.

Attach files to object entries.


Assets are not deleted from the Document Library when they’re removed from an object entry.

During field creation, you can use the Request Files field to determine how users upload files to the object’s entries:

Upload Directly from the User’s Computer: Users can upload a file to an entry using their operating system’s file selector. By default, this method saves the file to a private folder autogenerated for the Attachment field. This folder does not appear in the Liferay UI. However, if you enable Show Files in Documents and Media, uploaded files are saved to a folder in Documents and Media. By default, this folder uses the object definition’s name, but you can change it when configuring the field.

Upload or Select from Documents and Media Item Selector: Users can select from existing files in Documents and Media or upload a file using the item selector. Uploaded files are saved to the root folder in Documents and Media and can be managed like other files.

The Request Files field determines how users add files to the object's entries.


If desired, you can display hidden attachment field folders in Documents and Media by adding this portal property to your server:

After creating an attachment field, you can configure it in these ways:

Configuration Description
Accepted File Extensions Enter a list of accepted file extensions to determine the type of files users can upload to the field. Each extension must be separated by commas. Attachment fields support all file types accepted by Documents and Media.
Maximum File Size Enter the maximum file size accepted by the field. The default value is 100 MB. If desired, you can set the value to 0 to use the server’s Overall Maximum Upload Request Size property.
Storage Folder (for Show Files in Documents and Media) Enter a folder name to determine where uploaded files are stored in Documents and Media. By default, the folder uses the object definition’s name (e.g., /Employee, /TimeOffRequest).

Using Attachment Fields with APIs

A file must exist in Liferay before you can add it to an object entry’s attachment field using the headless API. Use the document library APIs to upload the file and retrieve its ID.

Pass the ID in the objects API call using this syntax: "[attachmentField]": [FileEntryId].


The example below adds an entry to an object named timeOffRequest. It adds a file with the ID 12345 to the attachment field document.

curl -X "POST" "http://localhost:8080/o/c/timeOffRequest?restrictFields=actions" \
     -H 'Content-Type: application/json' \
     -u '[email protected]:test' \
     -d $'{
  "document": 12345

Additional Information