Problem with uploads
Node.js version: v7.10.0 || v6.11.1 npm version: 4.2.0 Strapi version: 1.6.3 Operating system: MacOSx
Hi we currently have a problem testing the upload service of strapi. Everytime we upload a file the server does not respond and the connection closes after some time.
We were able to track it down to the upload service in /api/upload/services/upload.js
Using a valid token with this curl command:
curl \
-H 'Authorization:Bearer TOKEN_HERE' \
-F 'img_avatar=@/PATH/TO/FILE/test.png' http://localhost:1337/upload
any help would be much appreciated.
@piscis Thanks for reporting this issue. Do you have any logs that you can share with us to try to understand what happens?
sorry there is no log output the upload hangs, but debugging through the code I can see that a ReadableStream (part) was created and then the upload method is called. But the created promise in Line 25 actually never resolves:
https://github.com/strapi/strapi-generate-upload/blob/master/files/api/upload/services/upload.js#L24-L25
@piscis did you try to remove the isAuthorized in the routes.json file?
Where exactly the code stop working in the upload function (https://github.com/strapi/strapi-generate-upload/blob/master/files/api/upload/services/upload.js#L24-L25)?
@piscis, do you still have the issue?
I have the exact same issue on a freshly created app, the function inside Promise never executes. I guess what causes it is incompatibility with new nodejs (v6-v8). It's pretty easy to reproduce, just use strapi 1.6.3 and create a fresh new app with strapi cli then send an upload request.
Most likely happens if we use a node version with async/await support, so this is my quick fix: https://gist.github.com/wilonth/2be4e05b82d3f0f5a9bb668f75935955
Thanks a lot for your feedback @wilonth!