adminjs icon indicating copy to clipboard operation
adminjs copied to clipboard

How can I upload large files to s3 using adminjs dashboard without any issues?

Open haidyelnahass opened this issue 1 year ago • 1 comments

Describe the bug

I'm trying to upload files(40mbs+) to s3 using @adminjs\upload feature in adminjs dashboard. When I test on localhost, It uploads most of these files with no issues, but takes a very long time to upload. However, when I try on the deployed version on AWS EC2, I get the following error. Error: Request aborted at IncomingMessage.<anonymous> (/home/ubuntu/elearning-system-backend/node_modules/formidable/lib/incoming_form.js:122:19) at IncomingMessage.emit (node:events:513:28) at IncomingMessage.emit (node:domain:489:12) at IncomingMessage._destroy (node:_http_incoming:224:10) at _destroy (node:internal/streams/destroy:109:10) at IncomingMessage.destroy (node:internal/streams/destroy:71:5) at abortIncoming (node:_http_server:700:9) at socketOnClose (node:_http_server:694:3) at TLSSocket.emit (node:events:525:35) at TLSSocket.emit (node:domain:489:12)

Installed libraries and their versions

Node.js: 18.7.0
@adminjs/express: "^5.0.0", @adminjs/mongoose: "^3.0.0", @adminjs/passwords: "^3.0.0", @adminjs/upload: "^3.0.0", adminjs: "^6.0.1",

What I've tried to try to fix this issue

1- I've read some issues on github stating that using bodyparser with formidable sometimes produces this issue, however when I removed it, nothing changed. 2- Increasing the timeout doesn't really help either. 3- I've read in one issue about a package called formidable-serverless, but i have no idea where to use it since adminjs internally uses formidable.

What could be done to fix this issue?

haidyelnahass avatar Aug 08 '22 13:08 haidyelnahass

I'm not a fan of @adminjs/upload personally since it's useful for basic usage mostly where you only need to upload small files. I usually create my own upload tool based on project's needs.

In your case there's a chance that your server runs out of memory since @adminjs/upload doesn't stream the file and just sends everything in one go. My suggestion would be to create a custom component for your upload property which just uses a REST API endpoint to send a file and only updates the value after it's uploaded.

dziraf avatar Aug 09 '22 06:08 dziraf

I'm closing this issue due to the lack of response. If it still is the problem, please reopen the issue.

krzysztofstudniarek avatar Aug 16 '22 09:08 krzysztofstudniarek