multipart
Types from the Go package multipart (a library PocketBase builds on), as JavaScript sees them: they turn up as values of PocketBase's types and of hook events.
multipart.FileHeader
A FileHeader describes a file part of a multipart request.
| Member | Type | |
|---|---|---|
filename |
string |
|
header |
textproto.MIMEHeader |
|
size |
number |
|
open() |
(): File |
Open opens and returns the FileHeader's associated File. |
multipart.Part
A Part represents a single part in a multipart body.
| Member | Type | |
|---|---|---|
header |
textproto.MIMEHeader |
The headers of the body, if any, with the keys canonicalized in the same fashion that the Go http.Request headers are. For example, "foo-bar" changes case to "Foo-Bar" |
formName() |
(): string |
FormName returns the name parameter if p has a Content-Disposition of type "form-data". Otherwise it returns the empty string. |
fileName() |
(): string |
FileName returns the filename parameter of the Part's Content-Disposition header. If not empty, the filename is passed through filepath.Base (which is platform dependent) before being returned. |
read() |
(d: string|Array<number>): number |
Read reads the body of a part, after its headers and before the next part (if any) begins. |
close() |
(): void |
multipart.Reader
Reader is an iterator over parts in a MIME multipart body. Reader's underlying parser consumes its input as needed. Seeking isn't supported.
| Member | Type | |
|---|---|---|
readForm() |
(maxMemory: number): (Form) |
ReadForm parses an entire multipart message whose parts have a Content-Disposition of "form-data". It stores up to maxMemory bytes + 10MB (reserved for non-file parts) in memory. File parts which can't be stored in memory will be stored on disk in temporary files. It returns ErrMessageTooLarge if all non-file parts can't be stored in memory. |
nextPart() |
(): (Part) |
NextPart returns the next part in the multipart or an error. When there are no more parts, the error io.eOF is returned. |
nextRawPart() |
(): (Part) |
NextRawPart returns the next part in the multipart or an error. When there are no more parts, the error io.eOF is returned. |
multipart.Form
Form is a parsed multipart form. Its File parts are stored either in memory or on disk, and are accessible via the [*FileHeader]'s Open method. Its Value parts are stored as strings. Both are keyed by field name.
| Member | Type | |
|---|---|---|
value |
{ [key: string]: any } |
|
file |
{ [key: string]: any } |
|
removeAll() |
(): void |
RemoveAll removes any temporary files associated with a Form. |
multipart.File
File is an interface to access the file part of a multipart message. Its contents may be either stored in memory or on disk. If stored on disk, the File's underlying concrete type will be an *os.File.
Questions and comments
Comments are a GitHub Discussions thread; sign in with GitHub to post.