path.replace is not a function
elixiao opened this issue · comments
代码:
const formstream = require('formstream')
const fs = require('fs')
const path = require('path')
const filepath = path.join(__dirname, '1.jpg')
const file = fs.createReadStream(filepath)
const stream = formstream()
stream.file('uri', file)
stream.field('hello', 'world')
console.log(stream)
报错:
var ext = path.replace(/^.*[\.\/\\]/, '').toLowerCase();
^
TypeError: path.replace is not a function
at Mime.lookup (/project/node_modules/mime/mime.js:70:18)
at FormStream.file (/project/node_modules/formstream/lib/formstream.js:113:23)
at Object.<anonymous> (/project/form-data.js:35:8)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:829:12)
use the following syntax solves the problem:
stream.stream('uri', file, '1.jpg')