Beitrag
Teile dein Wissen.
How to determine file content type from CID and UnixFS metadata without fetching the file?
I am looking for a way to detect the content type of a file using its CID and UnixFS metadata, without having to fetch the actual file contents and analyze the payload using methods like Magic Numbers. I am particularly interested in how the IPFS Gateway determines the value to send in the Content-Type
response header.
- CID
Antworten
1In the current implementation, the file extension and magic bytes are used to determine the file type. For example, you can refer to the code snippet from Kubo's repository here to see how this is done.
However, we are also working on adding support for CBOR/JSON based on the codec from CID. This can be seen in the pull request here. With this enhancement, we will be able to skip the sniffing process for these specific data types.
In the future, we plan to leverage metadata from UnixFS, which can be in either protobuf or _headers file format. This will further enhance our ability to accurately determine the file type.
Please let me know if you have any further questions or if there's anything else I can assist you with.
Weißt du die Antwort?
Bitte melde dich an und teile sie.
The InterPlanetary File System (IPFS) is a protocol, hypermedia and file sharing peer-to-peer network for storing and sharing data in a distributed file system.
Verdiene deinen Anteil an 1000 Sui
Sammle Reputationspunkte und erhalte Belohnungen für deine Hilfe beim Wachstum der Sui-Community.