Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read/seek from a particular byte offset of a LOB #1643

Closed
ZachHaber opened this issue Feb 7, 2024 · 3 comments
Closed

Read/seek from a particular byte offset of a LOB #1643

ZachHaber opened this issue Feb 7, 2024 · 3 comments

Comments

@ZachHaber
Copy link

  1. Describe your new request in detail

I'm looking for a way to pull a set of bytes from a BLOB for downloading/streaming a file out of the database. Currently there doesn't appear to be any way to start the read stream from an offset or read a set of bytes from an offset (if you want to read more than a RAW buffer allows with DBMS_LOB.SUBSTR). The only approach I can find currently from the node side, would be to stream through the entire BLOB until the correct offset is reached, then stream the small piece I want and end the stream there - which seems entirely wasteful to me. And from the OracleDB side, the best answer I've seen so far on Stack Overflow was pulling out individual 2kb segments as raw buffers and then putting them together on the client-side, which is rather a lot of individual segments if you want a MB of data.

There appears to be prior art in the Python Oracledb package (LOB.Read()) and in the .net package (Blob.seek())

Either of these two functions would be suitable for my purposes, with the .seek() approach probably being the more versatile of the two since you can convert a read-stream to a buffer using node:stream/consumers and it is already a stream.

  1. Give supporting information about tools and operating systems. Give relevant product version numbers

OS: Win + WSL2(ubuntu 22.04.2)
nodejs: v18
node-oracledb: v6.3

@anthony-tuininga
Copy link
Member

There is an existing method which could fairly easily be adjusted to add optional arguments for the offset and the amount of data. I think this would be the simplest approach. Do you think that might address your request adequately?

@ZachHaber
Copy link
Author

Yup, I think that that would fit my request!
It wouldn't help as much as the seek functionality would for resuming a download, but for my particular use-case it should work fine!

@sharadraju
Copy link
Member

@ZachHaber This has been fixed as part of node-oracledb 6.4.

The fix is available here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants