我正在尝试在sailsjs(Followed this)中实现文件上传api,但在处理文件类型时会显示DeprecationWarning。
(node:23566) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
Sailsjs版本:0.12.14
我已经通过更改第55行解决了已弃用的警告 node_modules /帆/ node_modules /船长/ node_modules /多方/ index.js
这 self.uploadDir = options.uploadDir || os.tmpDir(); 至 self.uploadDir = options.uploadDir || os.tmpdir();
但是文件还没有进入请求。
request.file(' avatar')如下所示:其中avatar是文件类型的表单字段名称。
Upstream {
_fatalErrors: [],
isNoop: true,
_files: [],
timeouts:
{ untilFirstFileTimer:
Timeout {
_called: false,
_idleTimeout: 10000,
_idlePrev: [TimersList],
_idleNext: [TimersList],
_idleStart: 3295,
_onTimeout: [Function],
_timerArgs: undefined,
_repeat: null,
_destroyed: false,
[Symbol(asyncId)]: 302,
[Symbol(triggerAsyncId)]: 289 },
untilMaxBufferTimer:
Timeout {
_called: false,
_idleTimeout: 4500,
_idlePrev: [TimersList],
_idleNext: [TimersList],
_idleStart: 3295,
_onTimeout: [Function],
_timerArgs: undefined,
_repeat: null,
_destroyed: false,
[Symbol(asyncId)]: 304,
[Symbol(triggerAsyncId)]: 289 } },
_readableState:
ReadableState {
objectMode: true,
highWaterMark: 16,
buffer: BufferList { head: null, tail: null, length: 0 },
length: 0,
pipes: null,
pipesCount: 0,
flowing: null,
ended: false,
endEmitted: false,
reading: false,
sync: true,
needReadable: false,
emittedReadable: false,
readableListening: false,
resumeScheduled: false,
destroyed: false,
defaultEncoding: 'utf8',
awaitDrain: 0,
readingMore: false,
decoder: null,
encoding: null },
readable: true,
domain: null,
_events: {},
_eventsCount: 0,
_maxListeners: undefined,
fieldName: 'NOOP_avatar' }
------------
events.js:137
throw er; // Unhandled 'error' event
^
Error: EMAXBUFFER: An Upstream (`NOOP_avatar`) timed out before it was plugged into a receiver. It was still unused after waiting 4500ms. You can configure this timeout by changing the `maxTimeToBuffer` option.
at Timeout.<anonymous> (/usr/local/lib/node_modules/sails/node_modules/skipper/standalone/Upstream/Upstream.js:86:15)
at ontimeout (timers.js:458:11)
at tryOnTimeout (timers.js:296:5)
at Timer.listOnTimeout (timers.js:259:5)