Skip to content

Commit

Permalink
fix: handling of src data to format for sending over network
Browse files Browse the repository at this point in the history
  • Loading branch information
frankpagan committed Apr 1, 2024
1 parent 47e1ddd commit 591b84b
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,27 @@ class CoCreateFileSystem {
sendResponse(src, 200, { 'Content-Type': contentType })

function sendResponse(src, statusCode, headers) {
crud.wsManager.emit("setBandwidth", {
type: 'out',
data: src,
organization_id
});
try {
if (src instanceof Uint8Array) {
src = Buffer.from(src);
} else if (Buffer.isBuffer(src)) {
console.log('buffer')
return
}

res.writeHead(statusCode, headers);
return res.end(src);
if (typeof src === 'object') {
src = JSON.stringify(src);
}
crud.wsManager.emit("setBandwidth", {
type: 'out',
data: src,
organization_id
});
res.writeHead(statusCode, headers);
return res.end(src);
} catch (error) {
console.log(error)
}
}

async function getDefaultFile(fileName) {
Expand Down

0 comments on commit 591b84b

Please sign in to comment.