最終更新:2022-09-19 (月) 16:47:37 (582d)
Multer
Top / Multer
Multer is a node.js middleware for handling multipart/form-data, which is primarily used for uploading files.
https://github.com/expressjs/multer
ストレージ
使い方
const upload = multer({ dest: 'uploads/' })
パース結果
デフォルトの制限
fieldNameSize? Max field name size 100 bytes フィールド名の長さ fieldSize Max field value size (in bytes) 1MB フィールドのデータサイズ fields Max number of non-file fields Infinity fileSize For multipart forms, the max file size (in bytes) Infinity ファイルサイズ files For multipart forms, the max number of file fields Infinity 合計ファイルサイズ parts For multipart forms, the max number of parts (fields + files) Infinity 合計ファイルサイズ(フィールド含む) headerPairs For multipart forms, the max number of header key=>value pairs to parse 2000
アップロード処理
upload.single?(fieldname)
- Accept a single file with the name fieldname.
- req.file
upload.array?(fieldname[, maxCount])
- Accept an array of files, all with the name fieldname
- req.files?
upload.fields?(fields)
- Accept a mix of files, specified by fields.
upload.none?
- text-only
upload.any?
- Accepts all files that comes over the wire.
参考
関連
- busboy?