@multipart/form-data
Version:
Multipart/Form-Data And File Upload Middleware For Koa Written In ES6 And Optimised With JavaScript Compiler.
70 lines (65 loc) • 2.61 kB
text/xml
<types namespace="_multipart">
<import name="IncomingMessage" from="http" />
<import from="@typedefs/goa" name="Middleware" ns="_goa" />
<method name="FormDataFileFilter" desc="The function to control which files are accepted.">
<arg type="!http.IncomingMessage" name="req">The request object.</arg>
<arg type="!_multipart.FormDataFile" name="file">The file.</arg>
</method>
<interface name="FormData" desc="An instance to create middleware.">
<fn name="constructor">
<arg name="options" type="!_multipart.FormDataConfig" opt>
The options for the instance.
</arg>
Creates a new form-data instance.
</fn>
<fn return="!_goa.Middleware" name="single">
<arg string name="name">The name of the field.</arg>
Accept a single file.
</fn>
<fn return="!_goa.Middleware" name="array">
<arg string name="name">
The name of the field.
</arg>
<arg number name="maxFiles">
The maximum number of files.
</arg>
Accept multiple files.
</fn>
<fn return="!_goa.Middleware" name="fields">
<arg type="!Array<_multipart.FormDataField>" name="fields">
The fields to accept.
</arg>
Accept files according to the configured fields.
</fn>
<fn return="!_goa.Middleware" name="none">
Do not accept files, only fields.
</fn>
<fn return="!_goa.Middleware" name="any">
Accept any fields and files.
</fn>
</interface>
<interface name="FormDataStorageEngine">
<fn void name="_handleFile">
<arg type="!http.IncomingMessage" name="req">The request.</arg>
<arg type="!_multipart.FormDataFile" name="file">The file instance.</arg>
Saves the file asynchronously.
</fn>
<fn void name="_removeFile">
<arg type="!http.IncomingMessage" name="req">The request.</arg>
<arg type="!_multipart.FormDataFile" name="file">The file instance.</arg>
Removes the file asynchronously.
</fn>
</interface>
<type name="FormDataField" desc="The item to use in the `.fields` method.">
<prop name="name" string>The name of the field.</prop>
<prop opt name="maxCount" number>The maximum count of the field.</prop>
</type>
<interface name="FormDataError" desc="An error object which extends Error.">
<prop name="code" string>The error code.</prop>
<prop opt name="field" string>The field which resulted in error.</prop>
<!-- <static1 name="create">
<arg string name="code">The error code.</arg>
<arg string name="field" opt>The field name.</arg>
</static> -->
</interface>
</types>