Heroku 应用程序的免费层是否支持文件上传?
Does the free tier of Heroku apps support file upload?
我正在测试 MEAN 堆栈应用程序。我有一个处理文件上传的 Node.js 后端(通过 fs/multer
)。但是,当我尝试在生产中使用它时收到 503 错误。
本地一切正常。我正在使用 Heroku 的免费套餐;该层是否被锁定以不允许文件上传?
我目前尝试上传的(试过几次)只有36kb (.png
)。
查看我的日志并找到 503-
2018-10-26T20:39:24.352297+00:00 heroku[router]: at=error code=H13 desc="Connection closed without response" method=POST path="/media/upload" host=www.example.co.uk request_id=5388711c-bc99-4e42-9dbd-7b645fbefb43 fwd="90.222.69.255" dyno=web.1 connect=1ms service=130ms status=503 bytes=0 protocol=http
2018-10-26T20:39:24.306975+00:00 app[web.1]: (node:20) [DEP0013] DeprecationWarning: Calling an asynchronous function without callback is deprecated.
2018-10-26T20:39:24.307037+00:00 app[web.1]: (node:20) [DEP0013] DeprecationWarning: Calling an asynchronous function without callback is deprecated.
2018-10-26T20:39:24.318818+00:00 app[web.1]: fs.js:113
2018-10-26T20:39:24.318822+00:00 app[web.1]: throw err; // Forgot a callback but don't know where? Use NODE_DEBUG=fs
2018-10-26T20:39:24.318824+00:00 app[web.1]: ^
2018-10-26T20:39:24.318826+00:00 app[web.1]:
2018-10-26T20:39:24.318828+00:00 app[web.1]: Error: ENOENT: no such file or directory, mkdir './uploads/18'
文件上传不应自行生成 HTTP 503。您应该检查您的日志(通过 heroku logs
)以获取有关失败原因的更多信息。话虽如此,即使您解决了这个问题,您也可能需要从根本上改变您处理文件上传的方式。
所有 Heroku 等级都有 ephemeral filesystem. Any changes made to the filesystem are lost whenever your dyno restarts, which happens frequently(每天至少一次)。
official recommendation is to put uploaded files onto a third-party service like Amazon S3. The multer-s3
图书馆应该可以提供帮助。
我正在测试 MEAN 堆栈应用程序。我有一个处理文件上传的 Node.js 后端(通过 fs/multer
)。但是,当我尝试在生产中使用它时收到 503 错误。
本地一切正常。我正在使用 Heroku 的免费套餐;该层是否被锁定以不允许文件上传?
我目前尝试上传的(试过几次)只有36kb (.png
)。
查看我的日志并找到 503-
2018-10-26T20:39:24.352297+00:00 heroku[router]: at=error code=H13 desc="Connection closed without response" method=POST path="/media/upload" host=www.example.co.uk request_id=5388711c-bc99-4e42-9dbd-7b645fbefb43 fwd="90.222.69.255" dyno=web.1 connect=1ms service=130ms status=503 bytes=0 protocol=http
2018-10-26T20:39:24.306975+00:00 app[web.1]: (node:20) [DEP0013] DeprecationWarning: Calling an asynchronous function without callback is deprecated.
2018-10-26T20:39:24.307037+00:00 app[web.1]: (node:20) [DEP0013] DeprecationWarning: Calling an asynchronous function without callback is deprecated.
2018-10-26T20:39:24.318818+00:00 app[web.1]: fs.js:113
2018-10-26T20:39:24.318822+00:00 app[web.1]: throw err; // Forgot a callback but don't know where? Use NODE_DEBUG=fs
2018-10-26T20:39:24.318824+00:00 app[web.1]: ^
2018-10-26T20:39:24.318826+00:00 app[web.1]:
2018-10-26T20:39:24.318828+00:00 app[web.1]: Error: ENOENT: no such file or directory, mkdir './uploads/18'
文件上传不应自行生成 HTTP 503。您应该检查您的日志(通过 heroku logs
)以获取有关失败原因的更多信息。话虽如此,即使您解决了这个问题,您也可能需要从根本上改变您处理文件上传的方式。
所有 Heroku 等级都有 ephemeral filesystem. Any changes made to the filesystem are lost whenever your dyno restarts, which happens frequently(每天至少一次)。
official recommendation is to put uploaded files onto a third-party service like Amazon S3. The multer-s3
图书馆应该可以提供帮助。