Skip to content

Create IPIP: UnixFS and Gateway support for explicit MIME/Content-Type #364

Description

@lidel

This is a placeholder issue for creating IPIP to add support for storing explicit MIME/Content-Type in UnixFS DAG itself, like we already do for opt-in mode and mtime, and acting on its presence on Gateways.

There is alrernative approach to allow stating explicit content-type header via _headers file (similar to recently shipped _redirects) – some notes in #257

Context

UnixFSv2 never happened, but ability to explicitly specify Content-Type was one of my asks: ipld/legacy-unixfs-v2#11

Years later, we still guess Content-Type on gateways.
While it is fine for most of the time, but we should provide users with ability to explicitly set media type at the time of data onboarding.

Since 2018 we made some related development: we've added opt-in support for mode and mtime attributes. ~2020 (#217 (comment)). Support for mode and mtime was implemented in JS-IPFS a while ago, Kubo still has PR open (ipfs/go-unixfs#117).

Initial idea (details to be fleshed out in IPIP) is to introduce optional mtype similar way.
This is alternative to introducing _headers file mentioned in #257.

Ref.

TODO

  • wait until UnixFS specs land (Initial UnixFS specification #331)
  • create IPIP against UnixFS specs that
    • defines canonical way of storing explicit MIME (content/media type) in UnixFS root dag-pb blocks.
    • modifies Gateway spec to disable mime-sniffing and use sanitized (ASCII-only) value from dag-pb in Content-Type header
  • Create reference implementation in Kubo
    • adds optional --content-type to ipfs add
    • skip sniffing and set Content-Type header on gateway, if present

Activity

  1. added
    P1High: Likely tackled by core team if no one steps up
    need/triageNeeds initial labeling and prioritization
    on Jan 12, 2023
  2. changed the title [-]IPIP: UnixFS and Gateway support for explicit MIME/Content-Type[/-] [+]Create IPIP: UnixFS and Gateway support for explicit MIME/Content-Type[/+] on Jan 12, 2023
  3. lidel commented on Mar 8, 2023

    @lidel
    ContributorAuthor

    Need some help with historical context:

    • UnixFS 1.5 added Data.mode and Data.mtime fields
    • What we propose in this issue is "UnixFS 1.6" (tbd)
      • My initial idea was to add Content Type field as Data.ctype..
      • ... but I've noticed there is an existing Metadata.MimeType field in unixfs.proto already (seems to be not used for anything anywhere tho).

    Feels like there is a reason why Metadata was not used for mtime and mode (see js-ipfs-unixfs/unixfs.proto)

    @achingbrain @alanshaw do you remember why these fields landed in Data and not Metadata? Or who would be good person to ask?

  4. lidel commented on Aug 1, 2026

    @lidel
    ContributorAuthor

    Some thoughts in case someone wants to pick this up in the future:

    The UnixFS spec that merged in August 2025 has a legacy pb that already "reserves" a slot for this: message Metadata { string MimeType = 1; }, and DataType Metadata = 3, both marked "reserved for future use". Nothing implements either.

    IIRC some of discussions we had, reusing that legacy Metadata node type is a trap. Implementations already disagree on how Data_Metadata behaves, which is why boxo returns early on it and points at #316. The shape with precedent is a new optional field on Data, after mode (7) and mtime (8), the same way UnixFS 1.5 added those.

    Whichever shape, it is opt-in and changes the CID of anything that sets it, and it only pays off once gateways act on it, which is the #257 side.

    So the IPIP is still unwritten, but the design space is small now: choose the field, define precedence against extension sniffing and the existing default, and add gateway-conformance tests. Then implement it in both boxo/gateway and @helia/verified-fetch

  5. added
    P2Medium: Good to have, but can wait until someone steps up
    and removed
    P1High: Likely tackled by core team if no one steps up
    on Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium: Good to have, but can wait until someone steps upneed/community-inputNeeds input from the wider communityneed/triageNeeds initial labeling and prioritization

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions