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

Got stuck when uploading a file #9

Closed
shuai-zh opened this issue Apr 9, 2014 · 8 comments
Closed

Got stuck when uploading a file #9

shuai-zh opened this issue Apr 9, 2014 · 8 comments

Comments

@shuai-zh
Copy link

shuai-zh commented Apr 9, 2014

I added storage service feature to my app like this https://gist.github.com/chocstarfish/10224682,
and used the example code in here https://github.com/strongloop/loopback-storage-service/tree/master/example to test it.

The problem is when I upload a file, the request is always pending and after a while it throws an error like this:

http://localhost:3000/api/containers/container1/upload net::ERR_EMPTY_RESPONSE

image

and the back-end also logs an error:

Error: Request aborted

I think I am using the latest npm packages, then what is the problem?

@raymondfeng
Copy link
Member

Can u remove the bodyParser? It adds a middleware to handle multipart/form-data. Loopback rest is good.

Sent from my iPhone 5

On Apr 8, 2014, at 9:11 PM, Nicolas Zhang notifications@github.com wrote:

I added storage service feature to my app like this https://gist.github.com/chocstarfish/10224682,
and used the example code in here https://github.com/strongloop/loopback-storage-service/tree/master/example to test it.

The problem is when I upload a file, the request is always pending and after a while it throws an error like this:

http://localhost:3000/api/containers/container1/upload net::ERR_EMPTY_RESPONSE

and the back-end also logs an error:

Error: Request aborted
I think I am using the latest npm packages, then what is the problem?


Reply to this email directly or view it on GitHub.

@shuai-zh
Copy link
Author

@raymondfeng
If I remove the bodyParser, does it influence on the functionality of other APIs? I am adding the feature to the sls-sample-app. Or the storage service must be deployed on a separate node app?

@raymondfeng
Copy link
Member

No. loopback.rest middleware already handles json and form encoded media types.

Sent from my iPhone 5

On Apr 10, 2014, at 7:09 AM, Nicolas Zhang notifications@github.com wrote:

@raymondfeng
If I remove the bodyParser, does it influence on the functionality of other APIs? I am adding the feature to the sls-sample-app. Or the storage service must be deployed on a separate node app?


Reply to this email directly or view it on GitHub.

@shuai-zh
Copy link
Author

Yeah, it works, thank you~~~
ps: I think you should also remove the bodyParser from the sls-sample-app if that is not necessary.

@shuai-zh shuai-zh reopened this Apr 13, 2014
@shuai-zh
Copy link
Author

I think when I remove the bodyParser, the upload works fine but then the user/login does not work and it returns

{
  "error": {
    "name": "Error",
    "status": 400,
    "message": "request size did not match content length",
    "type": "request.size.invalid",
    "statusCode": 400,
    "received": 0,
    "expected": 54,
    "length": 54,
    "stack": "Error: request size did not match content length\n    at makeError (/MY_PATH/node_modules/loopback/node_modules/express/node_modules/connect/node_modules/raw-body/index.js:132:15)\n    at IncomingMessage.onEnd (/MY_PATH/node_modules/loopback/node_modules/express/node_modules/connect/node_modules/raw-body/index.js:102:13)\n    at IncomingMessage.g (events.js:180:16)\n    at IncomingMessage.EventEmitter.emit (events.js:92:17)\n    at _stream_readable.js:920:16\n    at process._tickCallback (node.js:415:13)"
  }
}

If I add back the bodyParser then the login works well but upload fails just as before.

So, I believe there is a bug either in loopback-storage-service or in loopback itself about it.

@raymondfeng
Copy link
Member

As a workaround for now, you can change https://gist.github.com/chocstarfish/10224682#file-gistfile1-js-L45 to be:

app.use(loopback.json());
app.use(loopback.urlencoded());

We'll investigate further.

@shuai-zh
Copy link
Author

@raymondfeng
Yes, your workaround works, thanks~

@shuai-zh shuai-zh reopened this Apr 13, 2014
@wiredots01
Copy link

i having the same issue always pending after submit. In what specific file did you remove the bodyParser from? is it in the passport?

@PArns PArns mentioned this issue Mar 5, 2017
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

3 participants