Comment attachments
P4 Code Review supports attaching files to comments in code reviews and jobs. To use comment attachments, P4 Code Review must have a depot where uploaded files can be stored. Configure a dedicated depot for comment attachment storage and ensure that the P4 Code Review admin user has permission to write to it.
The user who attaches a file is recorded in the P4 filelog.
Image attachments can be previewed after they are added to a comment. Attachments can also be downloaded using the download icon.
Changes to the comment attachment configuration require a configuration cache reload. You must be an admin or super user to reload the configuration cache. To reload the configuration:
-
Open the user menu (top-right corner of P4 Code Review).
-
Select System Information.
-
Open the Cache Info tab.
-
Click Reload Configuration.
If changes to the config.php file cause the P4 Code Review web interface to become unresponsive, remove the problematic configuration changes and clear the configuration cache by running:
rm -f /opt/perforce/swarm/data/cache/module-config-cache.php
On this page:
Comment attachment storage
P4 Code Review stores files attached to comments in a depot.
By default, P4 Code Review looks for a depot named //.swarm. Because P4 Code Review does not create this depot automatically, you must either:
-
Create the
//.swarmdepot -
Specify a different depot that the P4 Code Review admin user can write to.
It is best practice to use a dedicated depot such as //.swarm to store comment attachments. This helps prevent users from having direct access to attachment files outside of P4 Code Review.
Depot requirements
The depot used to store comment attachments must:
-
Be a classic depot. Other depot types such as
stream,unload,archiveandspecare not supported. To learn more, see Work with depots in the P4 CLI Reference -
Be a local depot. Remote depots are not supported.
-
Allow the P4 Code Review admin user to write to the depot.
-
Restrict access so that other users cannot access attachment files directly.
-
Use a depot directory that is not used to store any other files.
For information about depot permissions, see Access authorization in the P4 Server Administration Documentation.
Create a depot for comment attachments
We recommend using //.swarm for comment attachments because it is a dedicated depot that is not used to store any other files.
To create a //.swarm depot:
-
As a user with admin-level privileges, run
p4 depot .swarm -
Ensure that the P4 Code Review admin user has write access to the depot.
-
Configure permissions so that other users cannot access the depot.
To learn more on creating and configuring depots, see Working with depots in P4 Server Administration Documentation
Specify the location for the comment attachments
By default, P4 Code Review looks for a depot named //.swarm.
To use a different depot path for comment attachments, add the depot_storage configuration block to the SWARM_ROOT/data/config.php file.
depot_storage configuration block is mandatory if you want to add attachments to comments.If it is not included in the P4 Code Review configuration, the option to add attachments to comments is not available in the P4 Code Review UI.
Replace depot_name with the depot used to store comment attachments.
// this block should be a peer of 'p4'
'depot_storage' => array(
'base_path' => '//depot_name',
),
The P4 Code Review admin user must be able to write to this depot, and access should be restricted so that other users cannot access the stored attachments.
The base_path value can specify more than just a depot name.
For example //depot/perforce/.swarm is a valid location for comment attachments.
Image attachment previews
When an image is uploaded as a comment attachment, P4 Code Review generates a temporary blurred preview that can be displayed immediately while a thumbnail is being prepared.
P4 Code Review generates image thumbnails in the background. When a page containing the attachment is loaded, the blurred preview is displayed first and is automatically replaced when the thumbnail becomes available.
This behavior is expected and does not indicate a problem with the attachment.
Docker image thumbnail restrictions
For Docker deployments (2026.4 and later): The bundled Docker image restricts ImageMagick to a defined set of image formats used by P4 Code Review previews. Thumbnails continue to be generated for supported image formats, including PNG, JPEG, GIF, WEBP, BMP, TIFF, TGA, and PSD. Attachments in other image formats might not receive a thumbnail. When a thumbnail cannot be generated, P4 Code Review displays the file extension on the attachment card and the file remains available for download.
Troubleshooting image previews
If image attachments remain blurred and no thumbnail is displayed:
-
Verify that queue workers are running and processing background jobs.
-
Verify that thumbnail generation jobs are completing successfully.
-
Ensure that the
php-gdextension is installed for standard image formats such as JPEG and PNG. -
Ensure that the
php-imagickextension is installed for formats that require ImageMagick support, such as PDF, TIFF, and PowerPoint files. To learn more, see ImageMagick (imagick) extension for PHP.In Docker deployments, some image formats are intentionally blocked by the ImageMagick security policy and do not generate thumbnails even when the
php-imagickextension is installed.
Maximum comment attachment size
By default, the maximum file size of a single comment attachment is limited to:
-
Ubuntu: 8 MB
-
RHEL 8 and later: 2 MB
Increase the maximum attachment size
You can increase the maximum attachment size if required.
Ubuntu
Edit the following configurables in the .htaccess file:
-
php_value upload_max_filesize -
php_value post_max_size
RHEL 8 and later
Edit the following configurables in the /etc/php.ini file:
-
upload_max_filesize -
post_max_size