Reputation: 153
blob contents - PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiBmb2N1c2FibGU9ImZhbHNlIj48cGF0aCBkPSJNMTIgMWM2LjA3NCAwIDEwLjk5OSA0LjkyNSAxMC45OTkgMTEgMCA2LjA3NC00LjkyNSAxMC45OTktMTEgMTAuOTk5LTYuMDc0IDAtMTAuOTk5LTQuOTI1LTEwLjk5OS0xMUMxIDUuOTI1IDUuOTI1IDEgMTIgMXptMCAxOC4xNzNhNy4xNzQgNy4xNzQgMCAxMC0uMDAxLTE0LjM0NyA3LjE3NCA3LjE3NCAwIDAwMCAxNC4zNDd6bTAtMy42NTNhMy41MiAzLjUyIDAgMTEwLTcuMDQgMy41MiAzLjUyIDAgMDEwIDcuMDR6IiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjwvcGF0aD48L3N2Zz4K
const chainNumber = req.params.chainNumber;
try {
connection.execute(
`select logo
from chain_logos
where chain_id = :1`,
[chainNumber], {
outFormat: oracledb.ARRAYBUFFER
},
async function(err, result) {
if (err) {
console.error(err.message);
return;
}
connection.close();
const data = result.rows.map(row => ({
logo: Buffer.from(row[0]).toString('base64'),
logo2: Buffer.from(row[0], 'base64'),
logo3: row[0]
}))
return res.send({ data });
});
} catch (err) {
console.log('Error: ', err);
return res.send(`error returning chain logo`);
}
I'm only seeing an empty buffer returned from the code even though there is blob data: {"data":[{"logo":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},"logo3":{"_readableState":{"objectMode":false,"highWaterMark":16384,"buffer":{"head":null,"tail":null,"length":0},"length":0,"pipes":[],"flowing":null,"ended":false,"endEmitted":false,"reading":false,"sync":true,"needReadable":false,"emittedReadable":false,"readableListening":false,"resumeScheduled":false,"errorEmitted":false,"emitClose":true,"autoDestroy":true,"destroyed":false,"errored":null,"closed":false,"closeEmitted":false,"defaultEncoding":"utf8","awaitDrainWriters":null,"multiAwaitDrain":false,"readingMore":false,"decoder":null,"encoding":null},"_events":{},"_eventsCount":1,"_writableState":{"objectMode":false,"highWaterMark":16384,"finalCalled":false,"needDrain":false,"ending":false,"ended":false,"finished":false,"destroyed":false,"decodeStrings":false,"defaultEncoding":"utf8","length":0,"writing":false,"corked":0,"sync":true,"bufferProcessing":false,"writecb":null,"writelen":0,"afterWriteTickInfo":null,"buffered":[],"bufferedIndex":0,"allBuffers":true,"allNoop":true,"pendingcb":0,"prefinished":false,"errorEmitted":false,"emitClose":true,"autoDestroy":true,"errored":null,"closed":false},"allowHalfOpen":true,"offset":1,"_isActive":false,"_parentObj":{"_rowCache":[],"_processingStarted":false,"_convertedToStream":false,"_allowGetRowCall":false,"_isActive":false,"_parentObj":{"_events":{},"_eventsCount":1,"_dbObjectClasses":{},"_requestQueue":[],"_inProgress":true,"_pool":{"_events":{},"_eventsCount":2,"_queueTimeout":60000,"_queueMax":500,"_enableStatistics":false,"edition":"","events":false,"externalAuth":false,"homogeneous":true,"user":...
Upvotes: 0
Views: 856
Reputation: 10506
Overall, check the doc and examples.
By default LOBS will return as objects that you can stream from, or can call getData()
on.
If your LOBs are 1 GB or less, then you may want to force all LOBs to be returned as Strings or Buffers. Set these at the top of your code:
oracledb.fetchAsString = [ oracledb.CLOB ];
oracledb.fetchAsBuffer = [ oracledb.BLOB ];
Read the doc on Working with CLOB, NCLOB and BLOB Data for more detail.
The outformat
property refers to whether rows are represented by arrays or JS objects. There is no predefined constant oracledb.ARRAYBUFFER
. Or maybe you added this constant yourself?
Upvotes: 1