最終更新: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

ストレージ

  • multer.DiskStorage?
  • multer.MemoryStorage?

使い方

  • const upload = multer({ dest: 'uploads/' })

パース結果

デフォルトの制限

  • fieldNameSize?Max field name size100 bytesフィールド名の長さ
    fieldSizeMax field value size (in bytes)1MBフィールドのデータサイズ
    fieldsMax number of non-file fieldsInfinity
    fileSizeFor multipart forms, the max file size (in bytes)Infinityファイルサイズ
    filesFor multipart forms, the max number of file fieldsInfinity合計ファイルサイズ
    partsFor multipart forms, the max number of parts (fields + files)Infinity合計ファイルサイズ(フィールド含む)
    headerPairsFor multipart forms, the max number of header key=>value pairs to parse2000

アップロード処理

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?