Skip to content

Commit

Permalink
Fix buffer issues
Browse files Browse the repository at this point in the history
  • Loading branch information
brokoli777 committed Aug 8, 2024
1 parent b37dceb commit fb3dc5f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/routes/api/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ module.exports = (req, res) => {
}

const convertFileType = async (mimeType, bufferData, extension) => {
const data = bufferData
const data = bufferData.toString();

if (mimeType === 'text/plain') {
if (extension === 'txt') return data;
Expand Down
6 changes: 1 addition & 5 deletions tests/unit/get.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ describe('GET /v1/fragments', () => {
});

await fragment.save();
//await fragment.setData(imageBuffer.toString('base64'));
await fragment.setData(imageBuffer);

const getRes = await request(app)
Expand All @@ -218,15 +217,14 @@ describe('GET /v1/fragments', () => {
});

await fragment.save();
//await fragment.setData(imageBuffer.toString('base64'));
await fragment.setData(imageBuffer);

const getRes = await request(app)
.get(`/v1/fragments/${fragment.id}`)
.auth('user1@email.com', 'password1');

expect(getRes.statusCode).toBe(200);
expect(getRes.headers['content-type']).toBe('image/png; charset=utf-8');
expect(getRes.headers['content-type']).toBe('image/png');
});


Expand All @@ -246,8 +244,6 @@ describe('GET /v1/fragments', () => {
});

await fragment.save();
// Save the WebP buffer as a Base64 string
//await fragment.setData(webpBuffer.toString('base64'));
await fragment.setData(webpBuffer);

const getRes = await request(app)
Expand Down

0 comments on commit fb3dc5f

Please sign in to comment.