Skip to content

Commit 4b403ad

Browse files
lidelProximaNova
andauthored
docs: add /api/v0/add curl example (#2014)
Co-authored-by: ProximaNova <[email protected]>
1 parent fb13846 commit 4b403ad

File tree

4 files changed

+29
-11
lines changed

4 files changed

+29
-11
lines changed

docs/reference/kubo/rpc.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ I AM SERIOUS, DO NOT EDIT ANYTHING BELOW ;-D
4747
4848
-->
4949

50-
::: tip Generated on 2025-03-25, from kubo v0.34.1
50+
::: tip Generated on 2025-03-28, from kubo v0.34.1
5151
This document was autogenerated from [v0.34.1](https://github.com/ipfs/kubo/releases/tag/v0.34.1).
5252
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.
5353
:::
@@ -209,6 +209,12 @@ Argument `path` is of file type. This endpoint expects one or several files (dep
209209

210210
The `add` command not only allows adding files, but also uploading directories and complex hierarchies.
211211

212+
For example, to upload multiple files and have them show up in a specific folder structure:
213+
214+
```
215+
curl -sLk -XPOST -F "[email protected];filename=path1/file1.txt" -F \[email protected];filename=path2/file2.txt" "http://127.0.0.1:5001/api/v0/add?recursive=true&wrap-with-directory=true"
216+
```
217+
212218
This happens as follows: Every part in the multipart request is a *directory* or a *file* to be added to IPFS.
213219

214220
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
230236

231237
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.
232238

233-
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.
239+
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.
240+
234241

235242

236243
### Response

package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,12 @@
4646
"useTabs": false
4747
},
4848
"lint-staged": {
49-
"*.{js,json,css,less,scss,html,md,vue}": ["prettier --write"],
50-
"*.styl": ["stylus-supremacy format --replace"]
49+
"*.{js,json,css,less,scss,html,md,vue}": [
50+
"prettier --write"
51+
],
52+
"*.styl": [
53+
"stylus-supremacy format --replace"
54+
]
5155
},
5256
"husky": {
5357
"hooks": {

tools/http-api-docs/markdown.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,12 @@ Argument `+"`%s`"+` is of file type. This endpoint expects one or several files
352352
353353
The `+"`add`"+` command not only allows adding files, but also uploading directories and complex hierarchies.
354354
355+
For example, to upload multiple files and have them show up in a specific folder structure:
356+
357+
`+"```"+`
358+
curl -sLk -XPOST -F "[email protected];filename=path1/file1.txt" -F \[email protected];filename=path2/file2.txt" "http://127.0.0.1:5001/api/v0/add?recursive=true&wrap-with-directory=true"
359+
`+"```"+`
360+
355361
This happens as follows: Every part in the multipart request is a *directory* or a *file* to be added to IPFS.
356362
357363
Directory parts have a special content type `+"`application/x-directory`"+`. These parts do not carry any data. The part headers look as follows:
@@ -373,7 +379,8 @@ Content-Type: application/octet-stream
373379
374380
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.
375381
376-
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.
382+
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.
383+
377384
`)
378385
}
379386
return buf.String()

0 commit comments

Comments
 (0)