You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/how-to/address-ipfs-on-web.md
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -55,7 +55,7 @@ For example, a website can load static assets from content-addressed paths:
55
55
User agents that support IPFS, such as a browser with [ipfs-companion](https://docs.ipfs.io/install/ipfs-companion/), may recognize the `/ipfs/<CID>` content path and load the related asset over IPFS instead of HTTP. User agents without IPFS support still get the correct data from the original HTTP server.
56
56
:::
57
57
58
-
###Path gateway
58
+
## Path gateway
59
59
60
60
In the most basic scheme, a URL path used for content addressing is effectively a resource name without a canonical location. The HTTP server provides the location part, which makes it possible for browsers to interpret an IPFS content path as relative to the current server and just work without a need for any conversion:
When [origin-based security](https://en.wikipedia.org/wiki/Same-origin_policy) is needed, [CIDv1](../concepts/content-addressing.md#identifier-formats) in case-insensitive encoding such as Base32 or Base36 should be used in the subdomain:
The gateway provided by the IPFS daemon understands the `Host` header present in HTTP requests and will check if [DNSLink](../concepts/dnslink.md) exists for a specified [domain name](https://en.wikipedia.org/wiki/Fully_qualified_domain_name).
163
163
If DNSLink is present, the gateway will return content from a path resolved via DNS TXT record.
Copy file name to clipboardExpand all lines: docs/reference/http/gateway.md
+90-12Lines changed: 90 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -5,34 +5,112 @@ description: HTTP Gateway API reference for IPFS clients.
5
5
6
6
# HTTP Gateway reference
7
7
8
-
Gateways provide implementation and runtime agnostic HTTP interface for retrieving [content-addressed](/concepts/glossary/#content-addressing) data from IPFS with regular HTTP clients and libraries.
8
+
Gateways provide implementation and runtime agnostic HTTP interface for retrieving [content-addressed](../../concepts/glossary/#content-addressing) data from IPFS with regular HTTP clients and libraries.
9
9
10
-
::: tip Before you dive into low level specifications...
11
10
12
-
Make sure you understand [how to address IPFS on the web](../how-to/address-ipfs-on-web/), and what are differences between [Path](/how-to/address-ipfs-on-web/#path-gateway) and [Subdomain Gateways](/how-to/address-ipfs-on-web/#subdomain-gateway).
11
+
## API
12
+
13
+
### `GET /ipfs/{cid}[/{path}][?{params}]`
14
+
15
+
-`cid` is a [CID](https://docs.ipfs.io/concepts/glossary/#cid), the root identifier of the requested content path
16
+
-`path` – optional path under the root CID
17
+
18
+
Optional query parameters:
19
+
20
+
-`filename` sets the name returned in `Content-Disposition` HTTP header
21
+
-`download` set to `true` will skip rendering and force browsers to present a 'Save as' dialog
22
+
-`format` URL-friendly alternative to sending `Accept` header
23
+
24
+
::: tip Before you continue
25
+
26
+
Make sure you understand [how to address IPFS on the web](../../how-to/address-ipfs-on-web/), and what are differences between [Path](../../how-to/address-ipfs-on-web/#path-gateway) and [Subdomain Gateways](../how-to/address-ipfs-on-web/#subdomain-gateway).
27
+
28
+
:::
29
+
30
+
## Trusted vs trustless
31
+
32
+
Gateways can be used in a trusted or trustless way.
33
+
HTTP clients are in control, decide how much trust and work is delegated to the gateway.
34
+
35
+
### Delegating trust
36
+
37
+
By default, a gateway will take care of UnixFS deserialization and return reassembled files to the client, as if they were stored in a traditional HTTP server. This means all validation happens on the gateway, and clients trust the gateway is correctly validating content-addressed data before returning it to them.
When fetching a CID directly, one can include a `filename` parameter with file name to be used in `Content-Disposition` HTTP header: <https://ipfs.io/ipfs/bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi?filename=cat.jpg>
48
+
49
+
:::
50
+
51
+
### Trustless, verifiable retrieval
52
+
53
+
Clients capable of verifying content-addressed data on their own, should use [application/vnd.ipld.raw](https://www.iana.org/assignments/media-types/application/vnd.ipld.raw) and [application/vnd.ipld.car](https://www.iana.org/assignments/media-types/application/vnd.ipld.car) response types (raw [blocks](../concepts/glossary/#block) and [CARs](../concepts/glossary/#car)), and always ask for CIDs directly (`/ipfs/{cid}`).
54
+
55
+
#### Example: fetching a raw block
56
+
57
+
Using `Accept` HTTP header with [application/vnd.ipld.raw](https://www.iana.org/assignments/media-types/application/vnd.ipld.raw) type:
HTTP Gateway specification for IPFS implementers is available in [ipfs/specs](https://github.com/ipfs/specs/blob/main/http-gateways/#readme) repository.
94
+
Below are links for the most useful specifications.
16
95
17
-
<!-- TODO update this section (at least the links) when ipfs/specs PR lands -->
18
-
HTTP Gateway specification for IPFS implementers is available in [ipfs/specs](https://github.com/ipfs/specs/blob/main/http-gateways/#readme):
19
96
20
97
### HTTP
21
98
22
99
These are "low level" gateways that expose IPFS resources over HTTP protocol.
*[Path Gateway](https://github.com/ipfs/specs/blob/main/http-gateways/PATH_GATEWAY.md) ← **START HERE**, other types of gateway are specified as a delta against this specification.
102
+
*[Trustless Gateway](https://github.com/ipfs/specs/blob/main/http-gateways/TRUSTLESS_GATEWAY.md) is a subset that returns verifiable response types (raw [blocks](../concepts/glossary/#block) and [CARs](../concepts/glossary/#car))
26
103
27
104
### Web
28
105
29
106
Special types of gateway which leverage `Host` header in addition to URL `pathname`. Designed for website hosting and improved interoperability with web browsers and [origin-based security model](https://en.wikipedia.org/wiki/Same-origin_policy).
0 commit comments