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
9 changes: 9 additions & 0 deletions src/http/routes/s3/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,15 @@ export default async function routes(fastify: FastifyInstance) {
(route) => route.disableContentTypeParser
)

if (disableContentParser) {
localFastify.addContentTypeParser(
['application/json', 'text/plain', 'application/xml'],
function (request, payload, done) {
done(null)
}
)
}

localFastify.register(fastifyMultipart, {
limits: {
fields: 20,
Expand Down
14 changes: 14 additions & 0 deletions src/test/s3-protocol.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,20 @@ describe('S3 Protocol', () => {
expect(resp.$metadata.httpStatusCode).toEqual(200)
})

it('upload a broken JSON body using putObject ', async () => {
const bucketName = await createBucket(client)

const putObject = new PutObjectCommand({
Bucket: bucketName,
Key: 'test-1-put-object.jpg',
ContentType: 'application/json',
Body: '{"hello": "world"', // (no-closing tag)
})

const resp = await client.send(putObject)
expect(resp.$metadata.httpStatusCode).toEqual(200)
})

it('upload a file using putObject with custom metadata', async () => {
const bucketName = await createBucket(client)

Expand Down
Loading