Add support for Uint8Array in addition to Buffer
It might just be a question of updating the TypeScript types. At least the Node.js fs APIs support both. I don't know about other drivers.
I am less familiar with Uint8Array. Can you share when you will use it and does it make sense to convert it to buffer inside s3 or gcs drivers (if they don't support it)?
Technically, Buffer is built on Uint8Array (class Buffer extends Uint8Array). It just adds some utility methods on top of it.
There are many libraries which return binary data as Uint8Array (often to be usable in the browser). It may make sense to convert internally in the drivers (there is a very fast way to create a Buffer from Uint8Array, without copying the underlying data).
In my project, I'm using an image processing library which returns encoded PNG images as Uint8Array and I save them to the disk using adonis/drive
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Added to flydrive. https://flydrive.dev/docs/disk_api#getarraybuffer
Why is it called getArrayBuffer if it doesn't return an ArrayBuffer?
Lol. That slipped through the cracks.
I initially created getArrayBuffer, but later decided to mimic Bun's API and instead return a Uint8Array and rename the method to bytes. https://bun.sh/guides/read-file/uint8array
Do you agree that bytes is a better name and there is no need to have dedicated method for returning ArrayBuffer, since you can write Uint8Array.buffer to access it?
Yes, sgtm