- How to perform HTTP file uploads from your test scripts
- How to upload multiple files with one request
- How to make file data available to Artillery workers when running tests from AWS
This plugin is part of Artillery Pro and does not need to be installed separately.
http-file-uploads plugin adds support for
multipart/form-data form uploads in your test scripts, i.e. the mechanism that web browsers use to allow users to upload files to a server.
It can also be used to transfer arbitrary binary data with chunked transfer encoding.
The file upload plugin must be enabled in the
config section of your script.
To submit forms containing one or more file fields use the
formData attribute on the request and
fromFile to specify the file to be uploaded.
To upload more than one file, use multiple
File metadata may be customized:
To stream an arbitrary file content as the body of a request use
fromFile in the
body attribute of your request:
If the headers don’t specify the content-type, Artillery will check the file extension against a mapping of file extensions to content-types and use the proper content-type for the request.
If you are using Artillery to make PUT requests to pre-signed S3/CloudFront URLs, note that S3 requires that the
Content-Length header is set, even when using chunked transfer encoding.
You can use the
setContentLengthHeader option to tell Artillery to include the header. The value of the header will be set to the size of the file in bytes:
Note: This option should not be used with
multipart/related uploads, or with servers other than S3/CloudFront unless you are sure that you need it.
For file upload tests that run from the cloud (i.e. an AWS ECS cluster with
artillery run-test), the
filePaths property should be set to a list of all files and/or directories which are used by the scenarios.
Large amounts of file data will have an effect on the startup time of your tests. Consider using the smallest amount of data possible and using named tests (created with
artillery create-test) to improve the startup time of your tests.
Variables may be used with
fromFile to randomize the files being uploaded. For example:
If a file cannot be read, an
ENOENT error will be reported in Artillery’s output.