add
/api/v0/add
Add a file or directory to IPFS.
Request
- Syntax
- Example
curl "https://ipfs.infura.io:5001/api/v0/add?recursive=false&quiet=<value>&quieter=<value>&silent=<value>&progress=<value>&trickle=<value>&only-hash=<value>&wrap-with-directory=<value>&hidden=<value>&chunker=<value>&pin=true&raw-leaves=<value>&nocopy=<value>&fscache=<value>&cid-version=0&hash=sha2-256" \
-X POST \
-u "<API_KEY>:<API_KEY_SECRET>" \
-H "Content-Type: multipart/form-data" \
-F file=@"<file>"
curl "https://ipfs.infura.io:5001/api/v0/add?pin=false" \
-X POST \
-u "PROJECT_ID:PROJECT_SECRET" \
-H "Content-Type: multipart/form-data" \
-F file=@"/sample-result.json"
Request parameters
file
[Required] - The path to a file to be added to IPFS.quiet
[Optional] - Write minimal output.quieter
[Optional] - Write only final hash.silent
[Optional] - Write no output.progress
[Optional] - Stream progress data.trickle
[Optional] - Use trickle-dag format for daggeneration
.only-hash
[Optional] - Only chunk and hash - do not write to disk.wrap-with-directory
[Optional] - Wrap files with a directory object.pin
[Optional] - Pin this object when adding. The default istrue
.raw-leaves
[Optional] - Use raw blocks for leaf nodes. (Experimental)nocopy
[Optional] - Add the file using filestore. (Experimental)fscache
[Optional] - Check the filestore for pre-existing blocks. (Experimental)cid-version
[Optional]: Cid version. Non-zero value changes the default ofraw-leaves
totrue
. The default is0
. (Experimental)hash
[Optional]: Hash function to use. Setscid-version
to1
if used. The default issha2-256
. (Experimental)
Response
On success, the call to this endpoint will return with 200 and the following body:
Body
{
"Name": "sample-result.json",
"Hash": "QmSTkR1kkqMuGEeBS49dxVJjgHRMH6cUYa7D3tcHDQ3ea3",
"Size": "2120"
}
Result fields
Name
- Name of the object.Hash
- Hash of the uploaded object.Size
- Integer indication size in bytes.