Comment attachments

Swarm supports attaching arbitrary files to comments in code reviews and jobs.

To store files attached to comments, Swarm looks for a depot named //.swarm. As Swarm does not create this depot, you need to create it, or specify another depot that the Swarm admin user can write to.

To create a //.swarm depot, run the following as a user with admin-level privileges:

$ p4 depot .swarm

Ensure that the Swarm admin user can write to the //.swarm depot.

Tip

For more information and depot creation, see:


Perforce System Administrator's Guide: Using multiple depots

Specifying a depot path for comment attachments, if you prefer not to use the default //.swarm depot, is done with the depot_storage configuration block in the SWARM_ROOT/data/config.php file:

<?php
    // this block should be a peer of 'p4'
    'depot_storage' => array(
        'base_path'  => '//depot_name',
    ),

Replace depot_name with the depot where comment attachments should be stored. The Swarm admin needs to be able to write to this depot.

You can limit the size of comment attachments with the attachments configuration block in the SWARM_ROOT/data/config.php file:

<?php
    // this block should be a peer of 'p4'
    'attachments' => array(
        'max_file_size'  => 0, // the maximum file size to accept in bytes
    ),

Replace the 0 with the maximum file size in bytes that you want Swarm to accept for a comment attachment. If the file size is exceeded, users will see an error.

Note

Be aware that PHP's upload_max_filesize setting in SWARM_ROOT/public/.htaccess overrides max_file_size (which overrides the setting in PHP's php.ini). You can only use max_file_size to be more restrictive than the setting in SWARM_ROOT/public/.htaccess.

The default for upload_max_filesize is 8M (8 megabytes). Increase this limit if your commentors need to upload larger files.

You may also have to increase post_max_size. post_max_size should always be set larger or equal to upload_max_filesize, and Swarm's max_file_size should always be either unset, or set smaller or equal to upload_max_filesize, otherwise users will encounter unexpected rejection of their comment attachments.

See Handling file uploads: Common Pitfalls for more details.