How can I upload images / pdf files via native apps, over https request.
If I do send a POST request with enctype as multipart/form-data
can use this somewhere with below code
const fs = require('fs');
// Listen to incoming HTTP requests, can only be used on the server
WebApp.connectHandlers.use("/upload", function(req, res, next) {
var file = fs.createWriteStream('uploads');
console.log(req);
file.on('error',function(error) {
res.writeHead(500);
res.end("error",error);
})
file.on('finish',function() {
res.writeHead(200);
res.end("finish");
})
req.pipe(file)
});
Hello @ankibalyan , take look at this example: https://github.com/noris666/Meteor-Files-POST-Example
@dr-dimitru can I use Flow router, I'm using this router inside my app. or Just with use of WebApp
Better to use WebApp as it low-level back-end middleware.
@dr-dimitru how can replace this line Picker.middleware(_multerInstance.single('photo')); with WebApp not sure.
https://github.com/noris666/Meteor-Files-POST-Example/blob/master/avatars.example.js#L33
You need to use multipart-parser middleware first (there is many of them in NMP, and Picker is one of them). Like:
WebApp.connectHandlers.use(MultipartParser);
Of you can implement it yourself:
WebApp.connectHandlers.use( function (request, response, next) {
if(!!~request._parsedUrl.path.indexOf '/api/v1/upload' && request.method is 'POST') {
// Upload logic here
return response.end();
}
next();
});
@dr-dimitru Don't know why, I tried with webapp as well as picker, But in both the cases, I'm getting req.file as undefined. I tried uploading a file via very simple form as below
<form action="http://localhost:3000/api/v1/upload" method="POST" enctype="multipart/form-data">
<input type="file" name="file" />
<input type="submit" value="Upload File" />
</form>
Nodejs v6.9.1, Meteor 1.4.2.1
try to see what else in req via: console.log(req)
logs below:
`
I20161115-19:35:29.949(5.5)? IncomingMessage {
I20161115-19:35:29.950(5.5)? _readableState:
I20161115-19:35:29.950(5.5)? ReadableState {
I20161115-19:35:29.950(5.5)? objectMode: false,
I20161115-19:35:29.951(5.5)? highWaterMark: 16384,
I20161115-19:35:29.951(5.5)? buffer: [],
I20161115-19:35:29.951(5.5)? length: 0,
I20161115-19:35:29.952(5.5)? pipes: null,
I20161115-19:35:29.952(5.5)? pipesCount: 0,
I20161115-19:35:29.952(5.5)? flowing: false,
I20161115-19:35:29.953(5.5)? ended: true,
I20161115-19:35:29.954(5.5)? endEmitted: true,
I20161115-19:35:29.955(5.5)? reading: false,
I20161115-19:35:29.955(5.5)? sync: false,
I20161115-19:35:29.955(5.5)? needReadable: false,
I20161115-19:35:29.958(5.5)? emittedReadable: false,
I20161115-19:35:29.960(5.5)? readableListening: true,
I20161115-19:35:29.961(5.5)? resumeScheduled: false,
I20161115-19:35:29.961(5.5)? defaultEncoding: 'utf8',
I20161115-19:35:29.962(5.5)? ranOut: false,
I20161115-19:35:29.964(5.5)? awaitDrain: 0,
I20161115-19:35:29.964(5.5)? readingMore: false,
I20161115-19:35:29.964(5.5)? decoder: null,
I20161115-19:35:29.965(5.5)? encoding: null },
I20161115-19:35:29.965(5.5)? readable: false,
I20161115-19:35:29.965(5.5)? domain: null,
I20161115-19:35:29.971(5.5)? _events: { readable: [Function: bound ] },
I20161115-19:35:29.972(5.5)? _eventsCount: 1,
I20161115-19:35:29.973(5.5)? _maxListeners: undefined,
I20161115-19:35:29.973(5.5)? socket:
I20161115-19:35:29.973(5.5)? Socket {
I20161115-19:35:29.974(5.5)? _connecting: false,
I20161115-19:35:29.994(5.5)? _hadError: false,
I20161115-19:35:29.996(5.5)? _handle:
I20161115-19:35:29.997(5.5)? TCP {
I20161115-19:35:29.998(5.5)? bytesRead: 626349,
I20161115-19:35:29.998(5.5)? _externalStream: {},
I20161115-19:35:29.999(5.5)? fd: 17,
I20161115-19:35:30.001(5.5)? reading: true,
I20161115-19:35:30.002(5.5)? owner: [Circular],
I20161115-19:35:30.003(5.5)? onread: [Function: onread],
I20161115-19:35:30.010(5.5)? onconnection: null,
I20161115-19:35:30.011(5.5)? writeQueueSize: 0 },
I20161115-19:35:30.011(5.5)? _parent: null,
I20161115-19:35:30.011(5.5)? _host: null,
I20161115-19:35:30.012(5.5)? _readableState:
I20161115-19:35:30.012(5.5)? ReadableState {
I20161115-19:35:30.012(5.5)? objectMode: false,
I20161115-19:35:30.016(5.5)? highWaterMark: 16384,
I20161115-19:35:30.016(5.5)? buffer: [],
I20161115-19:35:30.017(5.5)? length: 0,
I20161115-19:35:30.023(5.5)? pipes: null,
I20161115-19:35:30.024(5.5)? pipesCount: 0,
I20161115-19:35:30.024(5.5)? flowing: true,
I20161115-19:35:30.024(5.5)? ended: false,
I20161115-19:35:30.026(5.5)? endEmitted: false,
I20161115-19:35:30.028(5.5)? reading: true,
I20161115-19:35:30.028(5.5)? sync: false,
I20161115-19:35:30.029(5.5)? needReadable: true,
I20161115-19:35:30.029(5.5)? emittedReadable: false,
I20161115-19:35:30.030(5.5)? readableListening: false,
I20161115-19:35:30.031(5.5)? resumeScheduled: false,
I20161115-19:35:30.031(5.5)? defaultEncoding: 'utf8',
I20161115-19:35:30.032(5.5)? ranOut: false,
I20161115-19:35:30.032(5.5)? awaitDrain: 0,
I20161115-19:35:30.033(5.5)? readingMore: false,
I20161115-19:35:30.033(5.5)? decoder: null,
I20161115-19:35:30.034(5.5)? encoding: null },
I20161115-19:35:30.035(5.5)? readable: true,
I20161115-19:35:30.035(5.5)? domain: null,
I20161115-19:35:30.035(5.5)? _events:
I20161115-19:35:30.036(5.5)? { end: [Object],
I20161115-19:35:30.036(5.5)? finish: [Function: onSocketFinish],
I20161115-19:35:30.036(5.5)? _socketEnd: [Function: onSocketEnd],
I20161115-19:35:30.037(5.5)? drain: [Object],
I20161115-19:35:30.037(5.5)? timeout: [Function],
I20161115-19:35:30.037(5.5)? error: [Object],
I20161115-19:35:30.038(5.5)? close: [Object],
I20161115-19:35:30.038(5.5)? data: [Function: socketOnData],
I20161115-19:35:30.040(5.5)? resume: [Function: onSocketResume],
I20161115-19:35:30.040(5.5)? pause: [Function: onSocketPause] },
I20161115-19:35:30.040(5.5)? _eventsCount: 10,
I20161115-19:35:30.041(5.5)? _maxListeners: undefined,
I20161115-19:35:30.041(5.5)? _writableState:
I20161115-19:35:30.042(5.5)? WritableState {
I20161115-19:35:30.042(5.5)? objectMode: false,
I20161115-19:35:30.043(5.5)? highWaterMark: 16384,
I20161115-19:35:30.043(5.5)? needDrain: false,
I20161115-19:35:30.044(5.5)? ending: false,
I20161115-19:35:30.046(5.5)? ended: false,
I20161115-19:35:30.046(5.5)? finished: false,
I20161115-19:35:30.046(5.5)? decodeStrings: false,
I20161115-19:35:30.047(5.5)? defaultEncoding: 'utf8',
I20161115-19:35:30.047(5.5)? length: 0,
I20161115-19:35:30.047(5.5)? writing: false,
I20161115-19:35:30.048(5.5)? corked: 0,
I20161115-19:35:30.048(5.5)? sync: true,
I20161115-19:35:30.053(5.5)? bufferProcessing: false,
I20161115-19:35:30.054(5.5)? onwrite: [Function],
I20161115-19:35:30.054(5.5)? writecb: null,
I20161115-19:35:30.055(5.5)? writelen: 0,
I20161115-19:35:30.055(5.5)? bufferedRequest: null,
I20161115-19:35:30.055(5.5)? lastBufferedRequest: null,
I20161115-19:35:30.056(5.5)? pendingcb: 0,
I20161115-19:35:30.056(5.5)? prefinished: false,
I20161115-19:35:30.064(5.5)? errorEmitted: false,
I20161115-19:35:30.067(5.5)? bufferedRequestCount: 0,
I20161115-19:35:30.067(5.5)? corkedRequestsFree: [Object] },
I20161115-19:35:30.067(5.5)? writable: true,
I20161115-19:35:30.067(5.5)? allowHalfOpen: true,
I20161115-19:35:30.068(5.5)? destroyed: false,
I20161115-19:35:30.068(5.5)? _bytesDispatched: 0,
I20161115-19:35:30.069(5.5)? _sockname: null,
I20161115-19:35:30.070(5.5)? _pendingData: null,
I20161115-19:35:30.070(5.5)? _pendingEncoding: '',
I20161115-19:35:30.071(5.5)? server:
I20161115-19:35:30.071(5.5)? Server {
I20161115-19:35:30.071(5.5)? domain: null,
I20161115-19:35:30.071(5.5)? _events: [Object],
I20161115-19:35:30.092(5.5)? _eventsCount: 4,
I20161115-19:35:30.093(5.5)? _maxListeners: undefined,
I20161115-19:35:30.093(5.5)? _connections: 1,
I20161115-19:35:30.093(5.5)? _handle: [Object],
I20161115-19:35:30.094(5.5)? _usingSlaves: false,
I20161115-19:35:30.094(5.5)? _slaves: [],
I20161115-19:35:30.095(5.5)? _unref: false,
I20161115-19:35:30.095(5.5)? allowHalfOpen: true,
I20161115-19:35:30.095(5.5)? pauseOnConnect: false,
I20161115-19:35:30.096(5.5)? httpAllowHalfOpen: false,
I20161115-19:35:30.096(5.5)? timeout: 5000,
I20161115-19:35:30.096(5.5)? _pendingResponseData: 0,
I20161115-19:35:30.097(5.5)? _connectionKey: '4:0.0.0.0:20037' },
I20161115-19:35:30.100(5.5)? _server:
I20161115-19:35:30.101(5.5)? Server {
I20161115-19:35:30.101(5.5)? domain: null,
I20161115-19:35:30.101(5.5)? _events: [Object],
I20161115-19:35:30.102(5.5)? _eventsCount: 4,
I20161115-19:35:30.102(5.5)? _maxListeners: undefined,
I20161115-19:35:30.103(5.5)? _connections: 1,
I20161115-19:35:30.103(5.5)? _handle: [Object],
I20161115-19:35:30.103(5.5)? _usingSlaves: false,
I20161115-19:35:30.104(5.5)? _slaves: [],
I20161115-19:35:30.105(5.5)? _unref: false,
I20161115-19:35:30.105(5.5)? allowHalfOpen: true,
I20161115-19:35:30.106(5.5)? pauseOnConnect: false,
I20161115-19:35:30.106(5.5)? httpAllowHalfOpen: false,
I20161115-19:35:30.106(5.5)? timeout: 5000,
I20161115-19:35:30.107(5.5)? _pendingResponseData: 0,
I20161115-19:35:30.107(5.5)? _connectionKey: '4:0.0.0.0:20037' },
I20161115-19:35:30.107(5.5)? _idleTimeout: 120000,
I20161115-19:35:30.108(5.5)? _idleNext:
I20161115-19:35:30.108(5.5)? Socket {
I20161115-19:35:30.108(5.5)? _connecting: false,
I20161115-19:35:30.109(5.5)? _hadError: false,
I20161115-19:35:30.109(5.5)? _handle: [Object],
I20161115-19:35:30.109(5.5)? _parent: null,
I20161115-19:35:30.110(5.5)? _host: null,
I20161115-19:35:30.110(5.5)? _readableState: [Object],
I20161115-19:35:30.110(5.5)? readable: true,
I20161115-19:35:30.111(5.5)? domain: null,
I20161115-19:35:30.111(5.5)? _events: [Object],
I20161115-19:35:30.111(5.5)? _eventsCount: 8,
I20161115-19:35:30.120(5.5)? _maxListeners: undefined,
I20161115-19:35:30.122(5.5)? _writableState: [Object],
I20161115-19:35:30.122(5.5)? writable: true,
I20161115-19:35:30.122(5.5)? allowHalfOpen: false,
I20161115-19:35:30.123(5.5)? destroyed: false,
I20161115-19:35:30.123(5.5)? _bytesDispatched: 17017,
I20161115-19:35:30.123(5.5)? _sockname: null,
I20161115-19:35:30.123(5.5)? _pendingData: null,
I20161115-19:35:30.124(5.5)? _pendingEncoding: '',
I20161115-19:35:30.124(5.5)? server: null,
I20161115-19:35:30.124(5.5)? _server: null,
I20161115-19:35:30.140(5.5)? _idleTimeout: 30000,
I20161115-19:35:30.141(5.5)? _idleNext: [Object],
I20161115-19:35:30.141(5.5)? _idlePrev: [Circular],
I20161115-19:35:30.142(5.5)? _idleStart: 147676,
I20161115-19:35:30.142(5.5)? read: [Function],
I20161115-19:35:30.143(5.5)? _consuming: true },
I20161115-19:35:30.143(5.5)? _idlePrev: { _idleNext: [Circular], _idlePrev: [Object] },
I20161115-19:35:30.143(5.5)? _idleStart: 147787,
I20161115-19:35:30.144(5.5)? parser:
I20161115-19:35:30.144(5.5)? HTTPParser {
I20161115-19:35:30.147(5.5)? '0': [Function: parserOnHeaders],
I20161115-19:35:30.149(5.5)? '1': [Function: parserOnHeadersComplete],
I20161115-19:35:30.150(5.5)? '2': [Function: parserOnBody],
I20161115-19:35:30.150(5.5)? '3': [Function: parserOnMessageComplete],
I20161115-19:35:30.151(5.5)? '4': [Function: onParserExecute],
I20161115-19:35:30.151(5.5)? _headers: [],
I20161115-19:35:30.151(5.5)? _url: '',
I20161115-19:35:30.152(5.5)? _consumed: true,
I20161115-19:35:30.152(5.5)? socket: [Circular],
I20161115-19:35:30.152(5.5)? incoming: [Circular],
I20161115-19:35:30.153(5.5)? outgoing: null,
I20161115-19:35:30.153(5.5)? maxHeaderPairs: 2000,
I20161115-19:35:30.153(5.5)? onIncoming: [Function: parserOnIncoming] },
I20161115-19:35:30.156(5.5)? on: [Function: socketOnWrap],
I20161115-19:35:30.156(5.5)? _paused: false,
I20161115-19:35:30.156(5.5)? read: [Function],
I20161115-19:35:30.157(5.5)? _consuming: true,
I20161115-19:35:30.157(5.5)? _httpMessage:
I20161115-19:35:30.157(5.5)? ServerResponse {
I20161115-19:35:30.158(5.5)? domain: null,
I20161115-19:35:30.158(5.5)? _events: [Object],
I20161115-19:35:30.158(5.5)? _eventsCount: 1,
I20161115-19:35:30.159(5.5)? _maxListeners: undefined,
I20161115-19:35:30.160(5.5)? output: [],
I20161115-19:35:30.160(5.5)? outputEncodings: [],
I20161115-19:35:30.161(5.5)? outputCallbacks: [],
I20161115-19:35:30.161(5.5)? outputSize: 0,
I20161115-19:35:30.161(5.5)? writable: true,
I20161115-19:35:30.162(5.5)? _last: false,
I20161115-19:35:30.162(5.5)? chunkedEncoding: false,
I20161115-19:35:30.162(5.5)? shouldKeepAlive: true,
I20161115-19:35:30.163(5.5)? useChunkedEncodingByDefault: true,
I20161115-19:35:30.163(5.5)? sendDate: true,
I20161115-19:35:30.163(5.5)? _removedHeader: {},
I20161115-19:35:30.164(5.5)? _contentLength: null,
I20161115-19:35:30.165(5.5)? _hasBody: true,
I20161115-19:35:30.165(5.5)? _trailer: '',
I20161115-19:35:30.166(5.5)? finished: false,
I20161115-19:35:30.173(5.5)? _headerSent: false,
I20161115-19:35:30.174(5.5)? socket: [Circular],
I20161115-19:35:30.174(5.5)? connection: [Circular],
I20161115-19:35:30.175(5.5)? _header: null,
I20161115-19:35:30.175(5.5)? _headers: null,
I20161115-19:35:30.195(5.5)? _headerNames: {},
I20161115-19:35:30.196(5.5)? _onPendingData: [Function: updateOutgoingData] } },
I20161115-19:35:30.197(5.5)? connection:
I20161115-19:35:30.198(5.5)? Socket {
I20161115-19:35:30.199(5.5)? _connecting: false,
I20161115-19:35:30.199(5.5)? _hadError: false,
I20161115-19:35:30.199(5.5)? _handle:
I20161115-19:35:30.200(5.5)? TCP {
I20161115-19:35:30.230(5.5)? bytesRead: 626349,
I20161115-19:35:30.231(5.5)? _externalStream: {},
I20161115-19:35:30.231(5.5)? fd: 17,
I20161115-19:35:30.235(5.5)? reading: true,
I20161115-19:35:30.235(5.5)? owner: [Circular],
I20161115-19:35:30.236(5.5)? onread: [Function: onread],
I20161115-19:35:30.249(5.5)? onconnection: null,
I20161115-19:35:30.256(5.5)? writeQueueSize: 0 },
I20161115-19:35:30.256(5.5)? _parent: null,
I20161115-19:35:30.257(5.5)? _host: null,
I20161115-19:35:30.257(5.5)? _readableState:
I20161115-19:35:30.258(5.5)? ReadableState {
I20161115-19:35:30.258(5.5)? objectMode: false,
I20161115-19:35:30.259(5.5)? highWaterMark: 16384,
I20161115-19:35:30.260(5.5)? buffer: [],
I20161115-19:35:30.260(5.5)? length: 0,
I20161115-19:35:30.260(5.5)? pipes: null,
I20161115-19:35:30.261(5.5)? pipesCount: 0,
I20161115-19:35:30.261(5.5)? flowing: true,
I20161115-19:35:30.261(5.5)? ended: false,
I20161115-19:35:30.262(5.5)? endEmitted: false,
I20161115-19:35:30.262(5.5)? reading: true,
I20161115-19:35:30.262(5.5)? sync: false,
I20161115-19:35:30.263(5.5)? needReadable: true,
I20161115-19:35:30.263(5.5)? emittedReadable: false,
I20161115-19:35:30.263(5.5)? readableListening: false,
I20161115-19:35:30.263(5.5)? resumeScheduled: false,
I20161115-19:35:30.265(5.5)? defaultEncoding: 'utf8',
I20161115-19:35:30.265(5.5)? ranOut: false,
I20161115-19:35:30.266(5.5)? awaitDrain: 0,
I20161115-19:35:30.266(5.5)? readingMore: false,
I20161115-19:35:30.267(5.5)? decoder: null,
I20161115-19:35:30.267(5.5)? encoding: null },
I20161115-19:35:30.267(5.5)? readable: true,
I20161115-19:35:30.268(5.5)? domain: null,
I20161115-19:35:30.268(5.5)? _events:
I20161115-19:35:30.268(5.5)? { end: [Object],
I20161115-19:35:30.269(5.5)? finish: [Function: onSocketFinish],
I20161115-19:35:30.269(5.5)? _socketEnd: [Function: onSocketEnd],
I20161115-19:35:30.274(5.5)? drain: [Object],
I20161115-19:35:30.276(5.5)? timeout: [Function],
I20161115-19:35:30.276(5.5)? error: [Object],
I20161115-19:35:30.276(5.5)? close: [Object],
I20161115-19:35:30.277(5.5)? data: [Function: socketOnData],
I20161115-19:35:30.277(5.5)? resume: [Function: onSocketResume],
I20161115-19:35:30.278(5.5)? pause: [Function: onSocketPause] },
I20161115-19:35:30.284(5.5)? _eventsCount: 10,
I20161115-19:35:30.285(5.5)? _maxListeners: undefined,
I20161115-19:35:30.285(5.5)? _writableState:
I20161115-19:35:30.286(5.5)? WritableState {
I20161115-19:35:30.286(5.5)? objectMode: false,
I20161115-19:35:30.286(5.5)? highWaterMark: 16384,
I20161115-19:35:30.287(5.5)? needDrain: false,
I20161115-19:35:30.287(5.5)? ending: false,
I20161115-19:35:30.287(5.5)? ended: false,
I20161115-19:35:30.287(5.5)? finished: false,
I20161115-19:35:30.288(5.5)? decodeStrings: false,
I20161115-19:35:30.288(5.5)? defaultEncoding: 'utf8',
I20161115-19:35:30.288(5.5)? length: 0,
I20161115-19:35:30.293(5.5)? writing: false,
I20161115-19:35:30.297(5.5)? corked: 0,
I20161115-19:35:30.315(5.5)? sync: true,
I20161115-19:35:30.315(5.5)? bufferProcessing: false,
I20161115-19:35:30.318(5.5)? onwrite: [Function],
I20161115-19:35:30.318(5.5)? writecb: null,
I20161115-19:35:30.318(5.5)? writelen: 0,
I20161115-19:35:30.319(5.5)? bufferedRequest: null,
I20161115-19:35:30.319(5.5)? lastBufferedRequest: null,
I20161115-19:35:30.329(5.5)? pendingcb: 0,
I20161115-19:35:30.348(5.5)? prefinished: false,
I20161115-19:35:30.350(5.5)? errorEmitted: false,
I20161115-19:35:30.352(5.5)? bufferedRequestCount: 0,
I20161115-19:35:30.353(5.5)? corkedRequestsFree: [Object] },
I20161115-19:35:30.354(5.5)? writable: true,
I20161115-19:35:30.355(5.5)? allowHalfOpen: true,
I20161115-19:35:30.356(5.5)? destroyed: false,
I20161115-19:35:30.356(5.5)? _bytesDispatched: 0,
I20161115-19:35:30.356(5.5)? _sockname: null,
I20161115-19:35:30.358(5.5)? _pendingData: null,
I20161115-19:35:30.359(5.5)? _pendingEncoding: '',
I20161115-19:35:30.360(5.5)? server:
I20161115-19:35:30.362(5.5)? Server {
I20161115-19:35:30.362(5.5)? domain: null,
I20161115-19:35:30.362(5.5)? _events: [Object],
I20161115-19:35:30.363(5.5)? _eventsCount: 4,
I20161115-19:35:30.363(5.5)? _maxListeners: undefined,
I20161115-19:35:30.364(5.5)? _connections: 1,
I20161115-19:35:30.370(5.5)? _handle: [Object],
I20161115-19:35:30.371(5.5)? _usingSlaves: false,
I20161115-19:35:30.375(5.5)? _slaves: [],
I20161115-19:35:30.376(5.5)? _unref: false,
I20161115-19:35:30.376(5.5)? allowHalfOpen: true,
I20161115-19:35:30.380(5.5)? pauseOnConnect: false,
I20161115-19:35:30.382(5.5)? httpAllowHalfOpen: false,
I20161115-19:35:30.382(5.5)? timeout: 5000,
I20161115-19:35:30.383(5.5)? _pendingResponseData: 0,
I20161115-19:35:30.383(5.5)? _connectionKey: '4:0.0.0.0:20037' },
I20161115-19:35:30.383(5.5)? _server:
I20161115-19:35:30.384(5.5)? Server {
I20161115-19:35:30.384(5.5)? domain: null,
I20161115-19:35:30.385(5.5)? _events: [Object],
I20161115-19:35:30.387(5.5)? _eventsCount: 4,
I20161115-19:35:30.390(5.5)? _maxListeners: undefined,
I20161115-19:35:30.390(5.5)? _connections: 1,
I20161115-19:35:30.390(5.5)? _handle: [Object],
I20161115-19:35:30.391(5.5)? _usingSlaves: false,
I20161115-19:35:30.391(5.5)? _slaves: [],
I20161115-19:35:30.391(5.5)? _unref: false,
I20161115-19:35:30.392(5.5)? allowHalfOpen: true,
I20161115-19:35:30.392(5.5)? pauseOnConnect: false,
I20161115-19:35:30.394(5.5)? httpAllowHalfOpen: false,
I20161115-19:35:30.402(5.5)? timeout: 5000,
I20161115-19:35:30.403(5.5)? _pendingResponseData: 0,
I20161115-19:35:30.403(5.5)? _connectionKey: '4:0.0.0.0:20037' },
I20161115-19:35:30.410(5.5)? _idleTimeout: 120000,
I20161115-19:35:30.418(5.5)? _idleNext:
I20161115-19:35:30.419(5.5)? Socket {
I20161115-19:35:30.419(5.5)? _connecting: false,
I20161115-19:35:30.419(5.5)? _hadError: false,
I20161115-19:35:30.419(5.5)? _handle: [Object],
I20161115-19:35:30.420(5.5)? _parent: null,
I20161115-19:35:30.420(5.5)? _host: null,
I20161115-19:35:30.420(5.5)? _readableState: [Object],
I20161115-19:35:30.420(5.5)? readable: true,
I20161115-19:35:30.421(5.5)? domain: null,
I20161115-19:35:30.421(5.5)? _events: [Object],
I20161115-19:35:30.423(5.5)? _eventsCount: 8,
I20161115-19:35:30.427(5.5)? _maxListeners: undefined,
I20161115-19:35:30.427(5.5)? _writableState: [Object],
I20161115-19:35:30.427(5.5)? writable: true,
I20161115-19:35:30.428(5.5)? allowHalfOpen: false,
I20161115-19:35:30.430(5.5)? destroyed: false,
I20161115-19:35:30.433(5.5)? _bytesDispatched: 17017,
I20161115-19:35:30.434(5.5)? _sockname: null,
I20161115-19:35:30.441(5.5)? _pendingData: null,
I20161115-19:35:30.442(5.5)? _pendingEncoding: '',
I20161115-19:35:30.442(5.5)? server: null,
I20161115-19:35:30.442(5.5)? _server: null,
I20161115-19:35:30.443(5.5)? _idleTimeout: 30000,
I20161115-19:35:30.443(5.5)? _idleNext: [Object],
I20161115-19:35:30.443(5.5)? _idlePrev: [Circular],
I20161115-19:35:30.443(5.5)? _idleStart: 147676,
I20161115-19:35:30.444(5.5)? read: [Function],
I20161115-19:35:30.451(5.5)? _consuming: true },
I20161115-19:35:30.451(5.5)? _idlePrev: { _idleNext: [Circular], _idlePrev: [Object] },
I20161115-19:35:30.452(5.5)? _idleStart: 147787,
I20161115-19:35:30.452(5.5)? parser:
I20161115-19:35:30.452(5.5)? HTTPParser {
I20161115-19:35:30.501(5.5)? '0': [Function: parserOnHeaders],
I20161115-19:35:30.502(5.5)? '1': [Function: parserOnHeadersComplete],
I20161115-19:35:30.502(5.5)? '2': [Function: parserOnBody],
I20161115-19:35:30.502(5.5)? '3': [Function: parserOnMessageComplete],
I20161115-19:35:30.503(5.5)? '4': [Function: onParserExecute],
I20161115-19:35:30.503(5.5)? _headers: [],
I20161115-19:35:30.503(5.5)? _url: '',
I20161115-19:35:30.504(5.5)? _consumed: true,
I20161115-19:35:30.504(5.5)? socket: [Circular],
I20161115-19:35:30.504(5.5)? incoming: [Circular],
I20161115-19:35:30.505(5.5)? outgoing: null,
I20161115-19:35:30.505(5.5)? maxHeaderPairs: 2000,
I20161115-19:35:30.505(5.5)? onIncoming: [Function: parserOnIncoming] },
I20161115-19:35:30.506(5.5)? on: [Function: socketOnWrap],
I20161115-19:35:30.506(5.5)? _paused: false,
I20161115-19:35:30.506(5.5)? read: [Function],
I20161115-19:35:30.507(5.5)? _consuming: true,
I20161115-19:35:30.507(5.5)? _httpMessage:
I20161115-19:35:30.507(5.5)? ServerResponse {
I20161115-19:35:30.507(5.5)? domain: null,
I20161115-19:35:30.508(5.5)? _events: [Object],
I20161115-19:35:30.508(5.5)? _eventsCount: 1,
I20161115-19:35:30.508(5.5)? _maxListeners: undefined,
I20161115-19:35:30.508(5.5)? output: [],
I20161115-19:35:30.509(5.5)? outputEncodings: [],
I20161115-19:35:30.509(5.5)? outputCallbacks: [],
I20161115-19:35:30.509(5.5)? outputSize: 0,
I20161115-19:35:30.510(5.5)? writable: true,
I20161115-19:35:30.510(5.5)? _last: false,
I20161115-19:35:30.510(5.5)? chunkedEncoding: false,
I20161115-19:35:30.510(5.5)? shouldKeepAlive: true,
I20161115-19:35:30.511(5.5)? useChunkedEncodingByDefault: true,
I20161115-19:35:30.511(5.5)? sendDate: true,
I20161115-19:35:30.511(5.5)? _removedHeader: {},
I20161115-19:35:30.512(5.5)? _contentLength: null,
I20161115-19:35:30.512(5.5)? _hasBody: true,
I20161115-19:35:30.512(5.5)? _trailer: '',
I20161115-19:35:30.512(5.5)? finished: false,
I20161115-19:35:30.513(5.5)? _headerSent: false,
I20161115-19:35:30.513(5.5)? socket: [Circular],
I20161115-19:35:30.513(5.5)? connection: [Circular],
I20161115-19:35:30.513(5.5)? _header: null,
I20161115-19:35:30.514(5.5)? _headers: null,
I20161115-19:35:30.514(5.5)? _headerNames: {},
I20161115-19:35:30.514(5.5)? _onPendingData: [Function: updateOutgoingData] } },
I20161115-19:35:30.515(5.5)? httpVersionMajor: 1,
I20161115-19:35:30.515(5.5)? httpVersionMinor: 1,
I20161115-19:35:30.515(5.5)? httpVersion: '1.1',
I20161115-19:35:30.516(5.5)? complete: true,
I20161115-19:35:30.516(5.5)? headers:
I20161115-19:35:30.516(5.5)? { 'x-forwarded-proto': 'http',
I20161115-19:35:30.517(5.5)? 'x-forwarded-port': '3000',
I20161115-19:35:30.517(5.5)? 'x-forwarded-for': '127.0.0.1',
I20161115-19:35:30.517(5.5)? 'accept-language': 'en-US,en;q=0.8',
I20161115-19:35:30.517(5.5)? 'accept-encoding': 'gzip, deflate, br',
I20161115-19:35:30.518(5.5)? dnt: '1',
I20161115-19:35:30.518(5.5)? accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
I20161115-19:35:30.518(5.5)? 'content-type': 'multipart/form-data; boundary=----WebKitFormBoundaryAc92FAKCUUJAZZsq',
I20161115-19:35:30.519(5.5)? 'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.100 Safari/537.36',
I20161115-19:35:30.519(5.5)? 'upgrade-insecure-requests': '1',
I20161115-19:35:30.519(5.5)? origin: 'null',
I20161115-19:35:30.519(5.5)? 'cache-control': 'max-age=0',
I20161115-19:35:30.520(5.5)? 'content-length': '625736',
I20161115-19:35:30.520(5.5)? connection: 'keep-alive',
I20161115-19:35:30.520(5.5)? host: 'localhost:3000' },
I20161115-19:35:30.520(5.5)? rawHeaders:
I20161115-19:35:30.521(5.5)? [ 'x-forwarded-proto',
I20161115-19:35:30.521(5.5)? 'http',
I20161115-19:35:30.521(5.5)? 'x-forwarded-port',
I20161115-19:35:30.522(5.5)? '3000',
I20161115-19:35:30.522(5.5)? 'x-forwarded-for',
I20161115-19:35:30.522(5.5)? '127.0.0.1',
I20161115-19:35:30.523(5.5)? 'accept-language',
I20161115-19:35:30.523(5.5)? 'en-US,en;q=0.8',
I20161115-19:35:30.523(5.5)? 'accept-encoding',
I20161115-19:35:30.524(5.5)? 'gzip, deflate, br',
I20161115-19:35:30.524(5.5)? 'dnt',
I20161115-19:35:30.524(5.5)? '1',
I20161115-19:35:30.525(5.5)? 'accept',
I20161115-19:35:30.525(5.5)? 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
I20161115-19:35:30.525(5.5)? 'content-type',
I20161115-19:35:30.526(5.5)? 'multipart/form-data; boundary=----WebKitFormBoundaryAc92FAKCUUJAZZsq',
I20161115-19:35:30.526(5.5)? 'user-agent',
I20161115-19:35:30.536(5.5)? 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.100 Safari/537.36',
I20161115-19:35:30.537(5.5)? 'upgrade-insecure-requests',
I20161115-19:35:30.537(5.5)? '1',
I20161115-19:35:30.538(5.5)? 'origin',
I20161115-19:35:30.538(5.5)? 'null',
I20161115-19:35:30.538(5.5)? 'cache-control',
I20161115-19:35:30.538(5.5)? 'max-age=0',
I20161115-19:35:30.539(5.5)? 'content-length',
I20161115-19:35:30.539(5.5)? '625736',
I20161115-19:35:30.539(5.5)? 'connection',
I20161115-19:35:30.539(5.5)? 'keep-alive',
I20161115-19:35:30.540(5.5)? 'host',
I20161115-19:35:30.540(5.5)? 'localhost:3000' ],
I20161115-19:35:30.540(5.5)? trailers: {},
I20161115-19:35:30.541(5.5)? rawTrailers: [],
I20161115-19:35:30.541(5.5)? upgrade: false,
I20161115-19:35:30.541(5.5)? url: '/api/v1/upload',
I20161115-19:35:30.542(5.5)? method: 'POST',
I20161115-19:35:30.542(5.5)? statusCode: null,
I20161115-19:35:30.542(5.5)? statusMessage: null,
I20161115-19:35:30.543(5.5)? client:
I20161115-19:35:30.543(5.5)? Socket {
I20161115-19:35:30.544(5.5)? _connecting: false,
I20161115-19:35:30.544(5.5)? _hadError: false,
I20161115-19:35:30.544(5.5)? _handle:
I20161115-19:35:30.544(5.5)? TCP {
I20161115-19:35:30.545(5.5)? bytesRead: 626349,
I20161115-19:35:30.545(5.5)? _externalStream: {},
I20161115-19:35:30.545(5.5)? fd: 17,
I20161115-19:35:30.546(5.5)? reading: true,
I20161115-19:35:30.546(5.5)? owner: [Circular],
I20161115-19:35:30.546(5.5)? onread: [Function: onread],
I20161115-19:35:30.546(5.5)? onconnection: null,
I20161115-19:35:30.547(5.5)? writeQueueSize: 0 },
I20161115-19:35:30.547(5.5)? _parent: null,
I20161115-19:35:30.548(5.5)? _host: null,
I20161115-19:35:30.548(5.5)? _readableState:
I20161115-19:35:30.548(5.5)? ReadableState {
I20161115-19:35:30.549(5.5)? objectMode: false,
I20161115-19:35:30.549(5.5)? highWaterMark: 16384,
I20161115-19:35:30.550(5.5)? buffer: [],
I20161115-19:35:30.550(5.5)? length: 0,
I20161115-19:35:30.550(5.5)? pipes: null,
I20161115-19:35:30.551(5.5)? pipesCount: 0,
I20161115-19:35:30.551(5.5)? flowing: true,
I20161115-19:35:30.551(5.5)? ended: false,
I20161115-19:35:30.551(5.5)? endEmitted: false,
I20161115-19:35:30.552(5.5)? reading: true,
I20161115-19:35:30.552(5.5)? sync: false,
I20161115-19:35:30.552(5.5)? needReadable: true,
I20161115-19:35:30.553(5.5)? emittedReadable: false,
I20161115-19:35:30.553(5.5)? readableListening: false,
I20161115-19:35:30.553(5.5)? resumeScheduled: false,
I20161115-19:35:30.554(5.5)? defaultEncoding: 'utf8',
I20161115-19:35:30.554(5.5)? ranOut: false,
I20161115-19:35:30.554(5.5)? awaitDrain: 0,
I20161115-19:35:30.555(5.5)? readingMore: false,
I20161115-19:35:30.555(5.5)? decoder: null,
I20161115-19:35:30.555(5.5)? encoding: null },
I20161115-19:35:30.556(5.5)? readable: true,
I20161115-19:35:30.556(5.5)? domain: null,
I20161115-19:35:30.563(5.5)? _events:
I20161115-19:35:30.564(5.5)? { end: [Object],
I20161115-19:35:30.564(5.5)? finish: [Function: onSocketFinish],
I20161115-19:35:30.565(5.5)? _socketEnd: [Function: onSocketEnd],
I20161115-19:35:30.565(5.5)? drain: [Object],
I20161115-19:35:30.565(5.5)? timeout: [Function],
I20161115-19:35:30.565(5.5)? error: [Object],
I20161115-19:35:30.566(5.5)? close: [Object],
I20161115-19:35:30.566(5.5)? data: [Function: socketOnData],
I20161115-19:35:30.566(5.5)? resume: [Function: onSocketResume],
I20161115-19:35:30.567(5.5)? pause: [Function: onSocketPause] },
I20161115-19:35:30.567(5.5)? _eventsCount: 10,
I20161115-19:35:30.567(5.5)? _maxListeners: undefined,
I20161115-19:35:30.568(5.5)? _writableState:
I20161115-19:35:30.568(5.5)? WritableState {
I20161115-19:35:30.568(5.5)? objectMode: false,
I20161115-19:35:30.568(5.5)? highWaterMark: 16384,
I20161115-19:35:30.569(5.5)? needDrain: false,
I20161115-19:35:30.569(5.5)? ending: false,
I20161115-19:35:30.569(5.5)? ended: false,
I20161115-19:35:30.569(5.5)? finished: false,
I20161115-19:35:30.570(5.5)? decodeStrings: false,
I20161115-19:35:30.570(5.5)? defaultEncoding: 'utf8',
I20161115-19:35:30.571(5.5)? length: 0,
I20161115-19:35:30.571(5.5)? writing: false,
I20161115-19:35:30.571(5.5)? corked: 0,
I20161115-19:35:30.572(5.5)? sync: true,
I20161115-19:35:30.572(5.5)? bufferProcessing: false,
I20161115-19:35:30.572(5.5)? onwrite: [Function],
I20161115-19:35:30.572(5.5)? writecb: null,
I20161115-19:35:30.572(5.5)? writelen: 0,
I20161115-19:35:30.573(5.5)? bufferedRequest: null,
I20161115-19:35:30.573(5.5)? lastBufferedRequest: null,
I20161115-19:35:30.573(5.5)? pendingcb: 0,
I20161115-19:35:30.573(5.5)? prefinished: false,
I20161115-19:35:30.574(5.5)? errorEmitted: false,
I20161115-19:35:30.574(5.5)? bufferedRequestCount: 0,
I20161115-19:35:30.574(5.5)? corkedRequestsFree: [Object] },
I20161115-19:35:30.574(5.5)? writable: true,
I20161115-19:35:30.575(5.5)? allowHalfOpen: true,
I20161115-19:35:30.575(5.5)? destroyed: false,
I20161115-19:35:30.575(5.5)? _bytesDispatched: 0,
I20161115-19:35:30.576(5.5)? _sockname: null,
I20161115-19:35:30.576(5.5)? _pendingData: null,
I20161115-19:35:30.576(5.5)? _pendingEncoding: '',
I20161115-19:35:30.576(5.5)? server:
I20161115-19:35:30.577(5.5)? Server {
I20161115-19:35:30.577(5.5)? domain: null,
I20161115-19:35:30.577(5.5)? _events: [Object],
I20161115-19:35:30.578(5.5)? _eventsCount: 4,
I20161115-19:35:30.578(5.5)? _maxListeners: undefined,
I20161115-19:35:30.578(5.5)? _connections: 1,
I20161115-19:35:30.578(5.5)? _handle: [Object],
I20161115-19:35:30.579(5.5)? _usingSlaves: false,
I20161115-19:35:30.579(5.5)? _slaves: [],
I20161115-19:35:30.579(5.5)? _unref: false,
I20161115-19:35:30.579(5.5)? allowHalfOpen: true,
I20161115-19:35:30.580(5.5)? pauseOnConnect: false,
I20161115-19:35:30.580(5.5)? httpAllowHalfOpen: false,
I20161115-19:35:30.580(5.5)? timeout: 5000,
I20161115-19:35:30.580(5.5)? _pendingResponseData: 0,
I20161115-19:35:30.581(5.5)? _connectionKey: '4:0.0.0.0:20037' },
I20161115-19:35:30.581(5.5)? _server:
I20161115-19:35:30.581(5.5)? Server {
I20161115-19:35:30.582(5.5)? domain: null,
I20161115-19:35:30.582(5.5)? _events: [Object],
I20161115-19:35:30.582(5.5)? _eventsCount: 4,
I20161115-19:35:30.583(5.5)? _maxListeners: undefined,
I20161115-19:35:30.583(5.5)? _connections: 1,
I20161115-19:35:30.592(5.5)? _handle: [Object],
I20161115-19:35:30.593(5.5)? _usingSlaves: false,
I20161115-19:35:30.593(5.5)? _slaves: [],
I20161115-19:35:30.594(5.5)? _unref: false,
I20161115-19:35:30.594(5.5)? allowHalfOpen: true,
I20161115-19:35:30.595(5.5)? pauseOnConnect: false,
I20161115-19:35:30.595(5.5)? httpAllowHalfOpen: false,
I20161115-19:35:30.595(5.5)? timeout: 5000,
I20161115-19:35:30.595(5.5)? _pendingResponseData: 0,
I20161115-19:35:30.596(5.5)? _connectionKey: '4:0.0.0.0:20037' },
I20161115-19:35:30.596(5.5)? _idleTimeout: 120000,
I20161115-19:35:30.596(5.5)? _idleNext:
I20161115-19:35:30.597(5.5)? Socket {
I20161115-19:35:30.597(5.5)? _connecting: false,
I20161115-19:35:30.597(5.5)? _hadError: false,
I20161115-19:35:30.598(5.5)? _handle: [Object],
I20161115-19:35:30.598(5.5)? _parent: null,
I20161115-19:35:30.598(5.5)? _host: null,
I20161115-19:35:30.599(5.5)? _readableState: [Object],
I20161115-19:35:30.599(5.5)? readable: true,
I20161115-19:35:30.599(5.5)? domain: null,
I20161115-19:35:30.600(5.5)? _events: [Object],
I20161115-19:35:30.600(5.5)? _eventsCount: 8,
I20161115-19:35:30.600(5.5)? _maxListeners: undefined,
I20161115-19:35:30.601(5.5)? _writableState: [Object],
I20161115-19:35:30.601(5.5)? writable: true,
I20161115-19:35:30.601(5.5)? allowHalfOpen: false,
I20161115-19:35:30.602(5.5)? destroyed: false,
I20161115-19:35:30.602(5.5)? _bytesDispatched: 17017,
I20161115-19:35:30.602(5.5)? _sockname: null,
I20161115-19:35:30.603(5.5)? _pendingData: null,
I20161115-19:35:30.603(5.5)? _pendingEncoding: '',
I20161115-19:35:30.603(5.5)? server: null,
I20161115-19:35:30.603(5.5)? _server: null,
I20161115-19:35:30.604(5.5)? _idleTimeout: 30000,
I20161115-19:35:30.604(5.5)? _idleNext: [Object],
I20161115-19:35:30.605(5.5)? _idlePrev: [Circular],
I20161115-19:35:30.605(5.5)? _idleStart: 147676,
I20161115-19:35:30.605(5.5)? read: [Function],
I20161115-19:35:30.605(5.5)? _consuming: true },
I20161115-19:35:30.606(5.5)? _idlePrev: { _idleNext: [Circular], _idlePrev: [Object] },
I20161115-19:35:30.606(5.5)? _idleStart: 147787,
I20161115-19:35:30.606(5.5)? parser:
I20161115-19:35:30.607(5.5)? HTTPParser {
I20161115-19:35:30.607(5.5)? '0': [Function: parserOnHeaders],
I20161115-19:35:30.607(5.5)? '1': [Function: parserOnHeadersComplete],
I20161115-19:35:30.607(5.5)? '2': [Function: parserOnBody],
I20161115-19:35:30.608(5.5)? '3': [Function: parserOnMessageComplete],
I20161115-19:35:30.608(5.5)? '4': [Function: onParserExecute],
I20161115-19:35:30.608(5.5)? _headers: [],
I20161115-19:35:30.608(5.5)? _url: '',
I20161115-19:35:30.609(5.5)? _consumed: true,
I20161115-19:35:30.609(5.5)? socket: [Circular],
I20161115-19:35:30.609(5.5)? incoming: [Circular],
I20161115-19:35:30.609(5.5)? outgoing: null,
I20161115-19:35:30.609(5.5)? maxHeaderPairs: 2000,
I20161115-19:35:30.610(5.5)? onIncoming: [Function: parserOnIncoming] },
I20161115-19:35:30.610(5.5)? on: [Function: socketOnWrap],
I20161115-19:35:30.610(5.5)? _paused: false,
I20161115-19:35:30.610(5.5)? read: [Function],
I20161115-19:35:30.611(5.5)? _consuming: true,
I20161115-19:35:30.611(5.5)? _httpMessage:
I20161115-19:35:30.611(5.5)? ServerResponse {
I20161115-19:35:30.612(5.5)? domain: null,
I20161115-19:35:30.612(5.5)? _events: [Object],
I20161115-19:35:30.612(5.5)? _eventsCount: 1,
I20161115-19:35:30.612(5.5)? _maxListeners: undefined,
I20161115-19:35:30.619(5.5)? output: [],
I20161115-19:35:30.620(5.5)? outputEncodings: [],
I20161115-19:35:30.620(5.5)? outputCallbacks: [],
I20161115-19:35:30.620(5.5)? outputSize: 0,
I20161115-19:35:30.620(5.5)? writable: true,
I20161115-19:35:30.621(5.5)? _last: false,
I20161115-19:35:30.621(5.5)? chunkedEncoding: false,
I20161115-19:35:30.622(5.5)? shouldKeepAlive: true,
I20161115-19:35:30.622(5.5)? useChunkedEncodingByDefault: true,
I20161115-19:35:30.622(5.5)? sendDate: true,
I20161115-19:35:30.622(5.5)? _removedHeader: {},
I20161115-19:35:30.623(5.5)? _contentLength: null,
I20161115-19:35:30.623(5.5)? _hasBody: true,
I20161115-19:35:30.623(5.5)? _trailer: '',
I20161115-19:35:30.624(5.5)? finished: false,
I20161115-19:35:30.624(5.5)? _headerSent: false,
I20161115-19:35:30.624(5.5)? socket: [Circular],
I20161115-19:35:30.624(5.5)? connection: [Circular],
I20161115-19:35:30.625(5.5)? _header: null,
I20161115-19:35:30.625(5.5)? _headers: null,
I20161115-19:35:30.625(5.5)? _headerNames: {},
I20161115-19:35:30.625(5.5)? _onPendingData: [Function: updateOutgoingData] } },
I20161115-19:35:30.626(5.5)? _consuming: true,
I20161115-19:35:30.626(5.5)? _dumped: false,
I20161115-19:35:30.626(5.5)? originalUrl: '/api/v1/upload',
I20161115-19:35:30.627(5.5)? _parsedUrl:
I20161115-19:35:30.627(5.5)? Url {
I20161115-19:35:30.627(5.5)? protocol: null,
I20161115-19:35:30.628(5.5)? slashes: null,
I20161115-19:35:30.628(5.5)? auth: null,
I20161115-19:35:30.628(5.5)? host: null,
I20161115-19:35:30.629(5.5)? port: null,
I20161115-19:35:30.629(5.5)? hostname: null,
I20161115-19:35:30.630(5.5)? hash: null,
I20161115-19:35:30.630(5.5)? search: null,
I20161115-19:35:30.630(5.5)? query: null,
I20161115-19:35:30.631(5.5)? pathname: '/api/v1/upload',
I20161115-19:35:30.631(5.5)? path: '/api/v1/upload',
I20161115-19:35:30.631(5.5)? href: '/api/v1/upload',
I20161115-19:35:30.632(5.5)? _raw: '/api/v1/upload' },
I20161115-19:35:30.632(5.5)? body: {},
I20161115-19:35:30.632(5.5)? read: [Function],
I20161115-19:35:30.632(5.5)? __onFinished: null }
`
Hey @noris666 ,
Could you please take a look on this issue. Related to your POST-upload example.
Sorry, guys. I need to go now. I'll be back tomorrow
@dr-dimitru no problem, i have some time.
@ankibalyan i look in your input with type file, you have name="file", in my example https://github.com/noris666/Meteor-Files-POST-Example/blob/master/avatars.example.js#L33 on that line we have name of field "photo", need replace this string and then i think you will get need result.
And also good point rewrite my example with "Webapp" implementation, before this issue i dont know about that features in Meteor :) lol 馃憤
If it is does not work, please share gist with your code :-) Thx.
@dr-dimitru @noris666 Thanks a lot for pointing out that, That was my mistake in understanding multer. after changing the input field name value, It worked well.
@ankibalyan Finally you use Picker or Webapp ? If you use Webapp i intrested look code.
@noris666 I just tested with picker right now, but I'll definitely do it with WebApp as there is no other use of Picker in my app.
@ankibalyan please let me know when you finish the implementation with WebApp, ok ?
Then i can update my example in better way of implementation.
OpenSource power 馃憤
@noris666 This was very simple to change to do with WebApp, I've uploaded on gist
WebApp.connectHandlers.use(_multerInstance.single('photo')).use("/api/v1/avatar/upload", Meteor.bindEnvironment(function(req, res, next) {
if (req.file !== undefined && req.file.mimetype.substr(0, 6) == 'image/' && req.headers.authtoken.length) {
const hashedToken = Accounts._hashLoginToken(req.headers.authtoken);
const user = Meteor.users.findOne({ 'services.resume.loginTokens.hashedToken': hashedToken });
if (user) {
Avatars.remove({ 'meta.userId': user._id });
fs.stat(req.file.path, function (_statError, _statData) {
const _addFileMeta = {
fileName: req.file.originalname,
type: req.file.mimetype,
size: req.file.size,
meta: {
userId: user._id,
username: user.username
}
};
fs.readFile(req.file.path, function (_readError, _readData) {
if (_readError) {
console.log(_readError);
} else {
Avatars.write(_readData, _addFileMeta, function (_uploadError, _uploadData) {
if (_uploadError) {
console.log(_uploadError);
} else {
console.log('upload data=', _uploadData);
fs.unlink(req.file.path); // remove temp upload
}
});
}
});
});
}
}
res.end();
}))
Thanks :)
@noris666 have you got a chance to update an example?
@ankibalyan thank you for contribution, great solution. Haven't used Accounts._hashLoginToken before. Usually just: Meteor.server.sessions[headers['x-mtok']].userId
@dr-dimitru yes of course, i will update in next days.
Most helpful comment
@noris666 This was very simple to change to do with WebApp, I've uploaded on gist
Thanks :)