From 6c7215e43accfe734757b45a975da6ab33dc63e2 Mon Sep 17 00:00:00 2001 From: ProximaNova Date: Wed, 26 Mar 2025 00:05:13 -0600 Subject: [PATCH 1/3] Update markdown.go --- tools/http-api-docs/markdown.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/http-api-docs/markdown.go b/tools/http-api-docs/markdown.go index d97e2afa9..6f9898bda 100644 --- a/tools/http-api-docs/markdown.go +++ b/tools/http-api-docs/markdown.go @@ -350,7 +350,7 @@ Argument `+"`%s`"+` is of file type. This endpoint expects one or several files if bodyArg.Endpoint == "/api/v0/add" { fmt.Fprintln(buf, ` -The `+"`add`"+` command not only allows adding files, but also uploading directories and complex hierarchies. +The `+"`add`"+` command not only allows adding files, but also uploading directories and complex hierarchies. (For example, in cURL, you can upload multiple files and have them show up in a folder by running `+"`curl -sLk -XPOST -F \"file=@file1.txt;filename=path1/file1.txt\" -F \"file=@file2.txt;filename=path2/file2.txt\" \"http://127.0.0.1:5001/api/v0/add?recursive=true&wrap-with-directory=true\"`"+`.) This happens as follows: Every part in the multipart request is a *directory* or a *file* to be added to IPFS. From c134198b7beff0dc365d6bcca4fc72d1da43c1de Mon Sep 17 00:00:00 2001 From: ProximaNova Date: Wed, 26 Mar 2025 00:08:57 -0600 Subject: [PATCH 2/3] Update markdown.go --- tools/http-api-docs/markdown.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/http-api-docs/markdown.go b/tools/http-api-docs/markdown.go index 6f9898bda..6ed8c1cd9 100644 --- a/tools/http-api-docs/markdown.go +++ b/tools/http-api-docs/markdown.go @@ -350,7 +350,7 @@ Argument `+"`%s`"+` is of file type. This endpoint expects one or several files if bodyArg.Endpoint == "/api/v0/add" { fmt.Fprintln(buf, ` -The `+"`add`"+` command not only allows adding files, but also uploading directories and complex hierarchies. (For example, in cURL, you can upload multiple files and have them show up in a folder by running `+"`curl -sLk -XPOST -F \"file=@file1.txt;filename=path1/file1.txt\" -F \"file=@file2.txt;filename=path2/file2.txt\" \"http://127.0.0.1:5001/api/v0/add?recursive=true&wrap-with-directory=true\"`"+`.) +The `+"`add`"+` command not only allows adding files, but also uploading directories and complex hierarchies. (For example, in cURL, you can upload multiple files and have them show up in a folder by running `+"`curl -sLk -XPOST -F \"file=@file1.txt;filename=path1/file1.txt\" -F \"file=@file2.txt;filename=path2/file2.txt\" \"http://127.0.0.1:5001/api/v0/add?recursive=true&wrap-with-directory=true\"`"+`; -F is specified multiple times along with recursive and wrap-with-directory.) This happens as follows: Every part in the multipart request is a *directory* or a *file* to be added to IPFS. From b183a51b2fc72827526a124cc0a2bc859c59d3d1 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Fri, 28 Mar 2025 20:33:07 +0100 Subject: [PATCH 3/3] docs: /api/v0/add curl example cleanup --- docs/reference/kubo/rpc.md | 11 +++++++++-- package-lock.json | 12 ++++++------ package.json | 8 ++++++-- tools/http-api-docs/markdown.go | 11 +++++++++-- 4 files changed, 30 insertions(+), 12 deletions(-) diff --git a/docs/reference/kubo/rpc.md b/docs/reference/kubo/rpc.md index 093bf53df..91b3e1e31 100644 --- a/docs/reference/kubo/rpc.md +++ b/docs/reference/kubo/rpc.md @@ -47,7 +47,7 @@ I AM SERIOUS, DO NOT EDIT ANYTHING BELOW ;-D --> -::: tip Generated on 2025-03-25, from kubo v0.34.1 +::: tip Generated on 2025-03-28, from kubo v0.34.1 This document was autogenerated from [v0.34.1](https://github.com/ipfs/kubo/releases/tag/v0.34.1). For issues and support, check out the [http-api-docs](https://github.com/ipfs/ipfs-docs/tree/main/tools/http-api-docs) generator on GitHub. ::: @@ -209,6 +209,12 @@ Argument `path` is of file type. This endpoint expects one or several files (dep The `add` command not only allows adding files, but also uploading directories and complex hierarchies. +For example, to upload multiple files and have them show up in a specific folder structure: + +``` +curl -sLk -XPOST -F "file=@file1.txt;filename=path1/file1.txt" -F \file=@file2.txt;filename=path2/file2.txt" "http://127.0.0.1:5001/api/v0/add?recursive=true&wrap-with-directory=true" +``` + This happens as follows: Every part in the multipart request is a *directory* or a *file* to be added to IPFS. Directory parts have a special content type `application/x-directory`. These parts do not carry any data. The part headers look as follows: @@ -230,7 +236,8 @@ Content-Type: application/octet-stream The above file includes its path in the "folderName/file.txt" hierarchy and IPFS will therefore be able to add it inside "folderName". The parts declaring the directories are optional when they have files inside and will be inferred from the filenames. In any case, a depth-first traversal of the directory tree is recommended to order the different parts making the request. -The `Abspath` header is included for filestore/urlstore features that are enabled with the `nocopy` option and it can be set to the location of the file in the filesystem (within the IPFS root), or to its full web URL. +NOTE: The `Abspath` header is included for experimental filestore/urlstore features that are enabled with the `nocopy` option and it can be set to the location of the file in the filesystem (within the IPFS root), or to its full web URL. + ### Response diff --git a/package-lock.json b/package-lock.json index 7729fe732..24a34b516 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5108,9 +5108,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001664", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001664.tgz", - "integrity": "sha512-AmE7k4dXiNKQipgn7a2xg558IRqPN3jMQY/rOsbxDhrd0tyChwbITBfiwtnqz8bi2M5mIWbxAYBvk7W7QBUS2g==", + "version": "1.0.30001707", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001707.tgz", + "integrity": "sha512-3qtRjw/HQSMlDWf+X79N206fepf4SOOU6SQLMaq/0KkZLmSjPxAkBOQQ+FxbHKfHmYLZFfdWsO3KA90ceHPSnw==", "dev": true, "funding": [ { @@ -25506,9 +25506,9 @@ } }, "caniuse-lite": { - "version": "1.0.30001664", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001664.tgz", - "integrity": "sha512-AmE7k4dXiNKQipgn7a2xg558IRqPN3jMQY/rOsbxDhrd0tyChwbITBfiwtnqz8bi2M5mIWbxAYBvk7W7QBUS2g==", + "version": "1.0.30001707", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001707.tgz", + "integrity": "sha512-3qtRjw/HQSMlDWf+X79N206fepf4SOOU6SQLMaq/0KkZLmSjPxAkBOQQ+FxbHKfHmYLZFfdWsO3KA90ceHPSnw==", "dev": true }, "caseless": { diff --git a/package.json b/package.json index 5c3f6f1d8..4bc731bf0 100644 --- a/package.json +++ b/package.json @@ -46,8 +46,12 @@ "useTabs": false }, "lint-staged": { - "*.{js,json,css,less,scss,html,md,vue}": ["prettier --write"], - "*.styl": ["stylus-supremacy format --replace"] + "*.{js,json,css,less,scss,html,md,vue}": [ + "prettier --write" + ], + "*.styl": [ + "stylus-supremacy format --replace" + ] }, "husky": { "hooks": { diff --git a/tools/http-api-docs/markdown.go b/tools/http-api-docs/markdown.go index 6ed8c1cd9..1a9e96557 100644 --- a/tools/http-api-docs/markdown.go +++ b/tools/http-api-docs/markdown.go @@ -350,7 +350,13 @@ Argument `+"`%s`"+` is of file type. This endpoint expects one or several files if bodyArg.Endpoint == "/api/v0/add" { fmt.Fprintln(buf, ` -The `+"`add`"+` command not only allows adding files, but also uploading directories and complex hierarchies. (For example, in cURL, you can upload multiple files and have them show up in a folder by running `+"`curl -sLk -XPOST -F \"file=@file1.txt;filename=path1/file1.txt\" -F \"file=@file2.txt;filename=path2/file2.txt\" \"http://127.0.0.1:5001/api/v0/add?recursive=true&wrap-with-directory=true\"`"+`; -F is specified multiple times along with recursive and wrap-with-directory.) +The `+"`add`"+` command not only allows adding files, but also uploading directories and complex hierarchies. + +For example, to upload multiple files and have them show up in a specific folder structure: + +`+"```"+` +curl -sLk -XPOST -F "file=@file1.txt;filename=path1/file1.txt" -F \file=@file2.txt;filename=path2/file2.txt" "http://127.0.0.1:5001/api/v0/add?recursive=true&wrap-with-directory=true" +`+"```"+` This happens as follows: Every part in the multipart request is a *directory* or a *file* to be added to IPFS. @@ -373,7 +379,8 @@ Content-Type: application/octet-stream The above file includes its path in the "folderName/file.txt" hierarchy and IPFS will therefore be able to add it inside "folderName". The parts declaring the directories are optional when they have files inside and will be inferred from the filenames. In any case, a depth-first traversal of the directory tree is recommended to order the different parts making the request. -The `+"`Abspath`"+` header is included for filestore/urlstore features that are enabled with the `+"`nocopy`"+` option and it can be set to the location of the file in the filesystem (within the IPFS root), or to its full web URL. +NOTE: The `+"`Abspath`"+` header is included for experimental filestore/urlstore features that are enabled with the `+"`nocopy`"+` option and it can be set to the location of the file in the filesystem (within the IPFS root), or to its full web URL. + `) } return buf.String()