A file to upload to the provider with MishkaPay.upload_file/1, such as a receipt, a download
log or a screenshot that answers a dispute. The provider keeps it and answers a
MishkaPay.File; its :id then goes in the dispute's evidence (MishkaPay.update_dispute/1).
A guarded_struct.
:provider,:tenant: as for a checkout.:purpose: what the file is for.:dispute_evidence, evidence for a dispute.:filename: the file's name, such as"receipt.pdf"; a plain name with no folder.:content_type: its MIME type, such as"application/pdf","image/jpeg"or"image/png".:content: the file's bytes. Read the file first (File.read/1); Mishka Pay never reads a path.
Each provider takes its own types and sizes, and refuses others before any request: Stripe
takes dispute evidence as PDF, JPEG or PNG, up to 5 MB. inspect/1 leaves out :content.
Summary
Functions
A sample %MishkaPay.File.Upload{} populated from defaults + type-based fallbacks.
Types
@type t() :: %MishkaPay.File.Upload{ content: binary(), content_type: String.t(), filename: String.t(), provider: String.t(), purpose: :dispute_evidence, tenant: term() | nil }
The struct that builder/1 returns.
| Field | Type | Required | Default | Description | Derives |
|---|---|---|---|---|---|
:provider | String.t() | yes | sanitize(trim) validate(not_nil_value, string, not_empty) | ||
:tenant | term() | nil | no | |||
:purpose | :dispute_evidence | yes | validate(not_nil_value, enum=Atom[dispute_evidence])<br>validator {MishkaPay.File, :purpose} | ||
:filename | String.t() | yes | sanitize(trim) validate(not_nil_value, string, not_empty, max_len=255)<br>validator {MishkaPay.File, :filename} | ||
:content_type | String.t() | yes | sanitize(trim, downcase) validate(not_nil_value, string, not_empty, max_len=255) | ||
:content | binary() | yes | validator {MishkaPay.File, :content} |