Skip to content

Commit

Permalink
Added error hanlding to verifyExtension() in S3File.
Browse files Browse the repository at this point in the history
  • Loading branch information
rizen committed Oct 25, 2024
1 parent ed6da2b commit 4c59719
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions ving/docs/change-log.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ outline: deep
* Fix a bug in redis client where it wouldn't connect to the AWS valkey/redis cluster.
* Fix a hydration mismatch in form inputs subtext.
* Fix a hydration mismatch in markdown inputs.
* Added error hanlding to verifyExtension() in S3File.

### 2024-10-24
* Installed dotenv for environment variables.
Expand Down
2 changes: 2 additions & 0 deletions ving/record/records/S3File.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ export class S3FileRecord extends VingRecord {
* await s3file.verifyExtension(['png','gif','jpeg','jpg'])
*/
async verifyExtension(whitelist, errorOnly = false) {
if (!isArray(whitelist))
throw ving.ouch(500, 'The whitelist must be an array of allowed file extensions defined in the ving schema.');
if (!whitelist.includes(this.get('extension')))
await this.markVerifiyFailed(`${this.get('filename')} needs to be one of ${whitelist.join(', ')}.`, errorOnly);
return true;
Expand Down

0 comments on commit 4c59719

Please sign in to comment.