|
| 1 | +import { Readable, Stream } from 'stream' |
| 2 | + |
| 3 | +declare class FormStream extends Stream { |
| 4 | + /** |
| 5 | + * Add a normal field to the form. |
| 6 | + * |
| 7 | + * @param name Name of field |
| 8 | + * @param value Value of field |
| 9 | + */ |
| 10 | + field(name: string, value: string): this |
| 11 | + |
| 12 | + /** |
| 13 | + * Add a local file to be uploaded to the form. |
| 14 | + * |
| 15 | + * @param name Name of file field |
| 16 | + * @param filepath Local path of the file to be uploaded |
| 17 | + * @param filename Name of the file (will be the base name of filepath if empty) |
| 18 | + * @param filesize Size of the file (will not generate Content-Length header if not specified) |
| 19 | + */ |
| 20 | + file( |
| 21 | + name: string, |
| 22 | + filepath: string, |
| 23 | + filename?: string, |
| 24 | + filesize?: number, |
| 25 | + ): this |
| 26 | + |
| 27 | + /** |
| 28 | + * Add a buffer as a file to upload. |
| 29 | + * |
| 30 | + * @param name Name of field |
| 31 | + * @param buffer The buffer to be uploaded |
| 32 | + * @param filename The file name that tells the remote server |
| 33 | + * @param contentType Content-Type (aka. MIME Type) of content (will be infered with filename if empty) |
| 34 | + */ |
| 35 | + buffer( |
| 36 | + name: string, |
| 37 | + buffer: Buffer, |
| 38 | + filename: string, |
| 39 | + contentType?: string, |
| 40 | + ): this |
| 41 | + |
| 42 | + /** |
| 43 | + * Add a readable stream as a file to upload. Event 'error' will be emitted if an error occured. |
| 44 | + * |
| 45 | + * @param name Name of field |
| 46 | + * @param stream A readable stream to be piped |
| 47 | + * @param filename The file name that tells the remote server |
| 48 | + * @param contentType Content-Type (aka. MIME Type) of content (will be infered with filename if empty) |
| 49 | + * @param size Size of the stream (will not generate Content-Length header if not specified) |
| 50 | + */ |
| 51 | + stream( |
| 52 | + name: string, |
| 53 | + stream: Readable, |
| 54 | + filename: string, |
| 55 | + contentType?: string, |
| 56 | + size?: number, |
| 57 | + ): this |
| 58 | + |
| 59 | + /** |
| 60 | + * Get headers for the request. |
| 61 | + * |
| 62 | + * @param additionalHeaders Additional headers |
| 63 | + */ |
| 64 | + headers(additionalHeaders?: Record<string, any>): Record<string, any> |
| 65 | +} |
| 66 | + |
| 67 | +declare const formStream: { |
| 68 | + new (): FormStream |
| 69 | + (): FormStream |
| 70 | +} |
| 71 | + |
| 72 | +export = formStream |
0 commit comments