subconsciousnetwork / noosphere

Noosphere is a protocol for thought; let's discover it together!
Apache License 2.0
665 stars 40 forks source link

Add canonical content-length header to memos #459

Open polyrainbow opened 1 year ago

polyrainbow commented 1 year ago

As a developer working on a webapp with Noosphere integration, I want to have a way to get the file size of a file stored in a sphere, without having to "consume" and free the file by calling SphereFile.intoBytes(). To achieve this functionality, all memos referring to byte streams should have a canonical/well-known content-length header. Also, the SphereFile interface of the NPM package should have a method to return the file size, e. g. SphereFile.size().

Related Discord chat: https://discord.com/channels/1003419732516552724/1003501801452085298/1125016166482579496

Related issue: https://github.com/subconsciousnetwork/noosphere/issues/43

cdata commented 1 year ago

This is important, thanks for filing it.

Content-Length will make sense for anything that we currently encode using paged BodyChunkIpld. This is almost everything except for the SphereIpld and its related substructure.

Perhaps putting it another way: any raw binary content can benefit from Content-Length, and any structured IPLD probably cannot.