swagger-api / swagger-api/swagger-ui
Download large files using Swagger UI
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 29k
- Forks
- 9.3k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 25
Description
I am trying to download large files (greater than 1 GB and less than 10 GB) using Swagger UI.
Checked examples and got it working for smaller files, where response returns a link to download a file, however, when the file is large, the response is not returned.
Thought it was a timeout issue and updated to an infinite timeout in the JavaScript code. Still the only result I get is a loading sign for more than 20 minutes for 1 GB file. (Cancelled the request after that).
Curl command for the same GET API works fine and returns result in around 8 seconds.
Have tried with the below approaches:
1.
res.setHeader('Content-Disposition', 'attachment; filename=' + fileName);
res.setHeader('Content-Type', 'application/octet-stream');
res.download(filePath, (downloadError) => {
// Error handling
});
res.writeHead(200, {
"Content-Type": "application/octet-stream",
"Content-Disposition": "attachment; filename=" + fileName
});
fs.createReadStream(filePath).pipe(res);
Is there a different implementation to handle large files in Swagger or is there something wrong in the way the javascript function is implemented?
Thanks.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue in Swagger UI with the reported streaming download responses for files between 1 GB and 10 GB, then compare the browser request with the working curl request. Determine whether the loading state is caused by Swagger UI or the browser response handling; done should include a confirmed fix or a documented limitation with a focused regression test if applicable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- api, frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100