add

/api/v0/add

Add a file or directory to IPFS.

REQUEST

1
POST 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
Copied!

REQUEST PARAMS

  • file [Required] - The path to a file to be added to IPFS.
  • recursive [Optional] - Add directory paths recursively. Default: “false”.
  • 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 dag generation.
  • only-hash [Optional] - Only chunk and hash - do not write to disk.
  • wrap-with-directory [Optional] - Wrap files with a directory object.
  • hidden [Optional] - Include files that are hidden. Only takes effect on recursive add. chunker [string]: Chunking algorithm to use.
  • pin [Optional] - Pin this object when adding. Default: “true”.
  • 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 [int]: Cid version. Non-zero value will change default of ‘raw-leaves’ to true. (experimental). Default: “0”.
  • hash [string]: Hash function to use. Will set Cid version to 1 if used. (experimental). Default: “sha2-256”.

EXAMPLE

Argument 'file' is of file type. This endpoint expects a file in the body of the request as multipart/form-data.
1
// POST
2
curl "https://ipfs.infura.io:5001/api/v0/add?pin=false" \
3
-X POST \
4
-H "Content-Type: multipart/form-data" \
5
-F file=@"/sample-result.json"
Copied!

RESPONSE

On success, the call to this endpoint will return with 200 and the following body:

RESULT FIELDS

  • Name - Name of the object
  • Hash - Hash of the uploaded object
  • Size - integer indication size in bytes

BODY

1
{
2
"Name": "sample-result.json",
3
"Hash": "QmSTkR1kkqMuGEeBS49dxVJjgHRMH6cUYa7D3tcHDQ3ea3",
4
"Size": "2120"
5
}
Copied!