Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Part has no pause method #296

Closed
seanadkinson opened this issue Aug 7, 2014 · 5 comments
Closed

Part has no pause method #296

seanadkinson opened this issue Aug 7, 2014 · 5 comments

Comments

@seanadkinson
Copy link

Hi there,

I'm trying to proxy a file upload through to a request.post() on another domain. I may be doing this wrong, but I think the issue is that the part doesn't have a pause() method.

var form = new formidable.IncomingForm();
form.parse(req);
form.onPart = function(part) {
    var r = request({
        method: 'POST',
        url: someUrl,
        headers: extractRequestHeaders(req)
    });
    r.form().append('file', part);
    r.pipe(res);
}

According to request docs, r.form().append can take a read stream such as fs.createReadStream().

Here is the result of the upload:

TypeError: Object #<Stream> has no method 'pause'
    at Function.DelayedStream.create (/Users/seanadkinson/code/hthu-assets/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/lib/delayed_stream.js:35:12)
    at FormData.CombinedStream.append (/Users/seanadkinson/code/hthu-assets/node_modules/request/node_modules/form-data/node_modules/combined-stream/lib/combined_stream.js:45:30)
    at FormData.append (/Users/seanadkinson/code/hthu-assets/node_modules/request/node_modules/form-data/lib/form_data.js:43:3)
    at IncomingForm.form.onPart (/Users/seanadkinson/code/hthu-assets/routes/eligibilityProxy.js:54:18)
    at MultipartParser.parser.onHeadersEnd (/Users/seanadkinson/code/hthu-assets/node_modules/formidable/lib/incoming_form.js:410:10)
    at callback (/Users/seanadkinson/code/hthu-assets/node_modules/formidable/lib/multipart_parser.js:102:31)
    at MultipartParser.write (/Users/seanadkinson/code/hthu-assets/node_modules/formidable/lib/multipart_parser.js:215:9)
    at IncomingForm.write (/Users/seanadkinson/code/hthu-assets/node_modules/formidable/lib/incoming_form.js:156:34)
    at IncomingMessage.<anonymous> (/Users/seanadkinson/code/hthu-assets/node_modules/formidable/lib/incoming_form.js:122:12)
    at IncomingMessage.emit (events.js:95:17)

Am I reading the error correctly? Is there a different way I should do what i'm doing?

Thank you, Sean

@KevinPoole
Copy link

Does anybody know anything about this? I have run into the same error for whatever reason.

@naugtur
Copy link

naugtur commented Oct 17, 2014

Looks like the stream implementation under that is not entirely compatible with new node streams.

To check if that's the case, you can try a workaround:
Check if piping through a generic duplex stream that can be paused helps.
Stuff like this can also be used: https://www.npmjs.org/package/pause-stream

@iliakan
Copy link
Contributor

iliakan commented Nov 6, 2014

That's because a part it is not a ReadableStream, but a generic Stream.

I guess that's an old history, probably Streams2 or even Stream3 in Node 0.11 would be good enough for @felixge to turn on them :)

@GrosSacASac
Copy link
Contributor

soon

@tunnckoCore
Copy link
Member

Probably fixed by #531

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants