Skip to content

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

@ZachHaber

Description

@ZachHaber
  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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions