Multipart file uploads

Auth, sessions & uploads

Stream a file from disk as one part of a multipart/form-data body alongside literal fields, extract the returned id, and confirm it — with full ${...} interpolation on values.

Browse all 52 demos 12 categories
Run it
$ loadr run examples/37-file-uploads.yaml
examples/37-file-uploads.yaml
# Multipart file uploads — Artillery's `http-file-uploads`.
#
# A POST with a multipart/form-data body that mixes literal fields with a file
# part read from disk. `file:` streams the file contents; `filename` and
# `content_type` set the part headers. Values support `${...}` interpolation.
#
#   loadr run examples/37-file-uploads.yaml
name: file-uploads
description: multipart/form-data upload with literal fields + a file part

defaults:
  http:
    base_url: https://api.example.com

scenarios:
  upload:
    executor: per-vu-iterations
    vus: 4
    iterations: 10
    flow:
      - request:
          name: upload
          method: POST
          url: /v1/files
          body:
            multipart:
              - { name: title, value: "report-vu${vu}" }
              - { name: visibility, value: private }
              - name: file
                file: data/upload.txt
                filename: report.txt
                content_type: text/plain
          extract:
            - { type: jsonpath, name: file_id, expression: "$.id" }
          checks:
            - { type: status, equals: 201 }
            - { type: jsonpath, expression: "$.id", exists: true }
      - request:
          name: confirm
          url: "/v1/files/${file_id}"
          checks: [ { type: status, equals: 200 } ]

thresholds:
  checks: [ "rate>0.99" ]
  http_req_duration: [ "p(95)<1500" ]

View raw: examples/37-file-uploads.yaml

Related files: data/upload.txt

What it shows

  • multipart body with a file: part
  • Per-part filename / content_type
  • Extract + reuse the returned id