Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add /api/v0/add curl example #2014

Merged
merged 3 commits into from
Apr 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions docs/reference/kubo/rpc.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
:::
Expand Down Expand Up @@ -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 "[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"
```

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:
Expand All @@ -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
Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
9 changes: 8 additions & 1 deletion tools/http-api-docs/markdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,12 @@ Argument `+"`%s`"+` is of file type. This endpoint expects one or several files

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 "[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"
`+"```"+`

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:
Expand All @@ -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()
Expand Down