Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/server/routes/buckets.js
Original file line number Diff line number Diff line change
Expand Up @@ -1192,8 +1192,9 @@ BucketsRouter.prototype.startUpload = async function (req, res, next) {
}
}

const MAX_MULTIPARTS = 10000;
const multiparts = parseInt(req.query.multiparts || 1);
if (!Number.isInteger(multiparts) || multiparts < 1) {
if (!Number.isInteger(multiparts) || multiparts < 1 || multiparts > MAX_MULTIPARTS) {
return next(new errors.BadRequestError('Invalid multiparts value'));
}

Expand Down
13 changes: 13 additions & 0 deletions tests/lib/e2e/buckets/files.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,19 @@ describe('Bridge E2E Tests', () => {

})

it('When a user wants to upload a file with multiparts exceeding the maximum allowed, it should fail with 400', async () => {
const { body: { id: bucketId } } = await testServer
.post('/buckets')
.set('Authorization', getAuth(testUser))
.expect(201)

const response = await testServer.post(`/v2/buckets/${bucketId}/files/start?multiparts=10001`)
.set('Authorization', getAuth(testUser))
.send({ uploads: [{ index: 0, size: 1000 }] })

expect(response.status).toBe(400)
expect(response.body.error).toBe('Invalid multiparts value')
})

it('When a user finishes to upload a file with single part upload, the user can finish the upload with a hash for the file', async () => {

Expand Down
Loading