Skip to content

Commit

Permalink
Allow zero-sized files
Browse files Browse the repository at this point in the history
We were rejecting files of size zero; this may have been due to a past
constraint within Permanent (and that constraint may still exist
somewhere in the backend), but we ultimately do want to let people
upload empty files since files of zero size can legitimately exist.

Issue #62 Support zero-sized files
  • Loading branch information
slifty committed Mar 30, 2023
1 parent 0e6d48b commit 75d8277
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions src/tests/fileDestinationUrlApi.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,20 @@ describe('fileDestinationUrl API #int', () => {

expect(response.body).toMatchSnapshot();
});

it('should return an S3 URL when a zero-sized file is passed', async () => {
const response = await agent
.post('/api/fileDestinationUrl')
.send({
bucket: 'permanent-tests',
path: 'my_example_path',
fileType: 'image/png',
fileName: 'example.png',
maxSize: 0,
})
.expect(200);

expect(response.body).toMatchSnapshot();
});
});
});
2 changes: 1 addition & 1 deletion src/validators/validateCreateFileDestinationUrlParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const validateCreateFileDestinationUrlParams = (
bucket: Joi.string().min(3, 'utf8').max(63, 'utf8').required(),
fileName: Joi.string().max(1024, 'utf8'),
fileType: Joi.string().required(),
maxSize: Joi.number().min(1).required(),
maxSize: Joi.number().min(0).required(),
path: Joi.string(),
}).validate(
data,
Expand Down

0 comments on commit 75d8277

Please sign in to comment.