# 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" ]
