feat: refactor memory and disk storage classes, improve error handling and file size validation#1276
Open
kalebalebachew wants to merge 2 commits intoexpressjs:mainfrom
Open
feat: refactor memory and disk storage classes, improve error handling and file size validation#1276kalebalebachew wants to merge 2 commits intoexpressjs:mainfrom
kalebalebachew wants to merge 2 commits intoexpressjs:mainfrom
Conversation
…ze validation - Refactored DiskStorage to use async/await for better readability and error handling. - Added file size validation in DiskStorage with a configurable maxSize option. - Improved stream error handling in both file.stream and outStream. - Ensured proper resource cleanup by destroying streams if file size exceeds the limit. - Updated MemoryStorage for consistent error handling and robustness.
IamLizu
reviewed
Sep 14, 2024
IamLizu
suggested changes
Sep 14, 2024
storage/disk.js
Outdated
| class DiskStorage { | ||
| constructor (opts = {}) { | ||
| this.getFilename = opts.filename || getFilename | ||
| this.maxSize = opts.maxSize || Infinity |
Member
There was a problem hiding this comment.
There seems to be a trailing space at the end and standard is unable to fix it automatically. Please remove it.
Author
|
I think it should be fixed by now. let me know what to improve if u have one. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
maxSizeoption in DiskStorage to enforce file size limits, with proper stream destruction on overflow.constfor immutable values for better code consistency and clarity.