Skip to main content

URL#

https://<endpoint-api-host>/pinning/pinFile

For example, pinFile API URL of Endpoint 'Hong Kong' is:

https://api-hk.decoo.io/pinning/pinFile

Description#

Upload and pin a file to Decoo, which will also eventually be stored to Crust network.

note

To provide consistent programming model with pinByHash, a pin job is also generated for each API call. Likewise, you can query the status of the job using pinJobs API.

Type#

POST

Headers#

"UserAccessToken": "<YOUR_ACCESS_TOKEN>"

Body#

The body of this request needs to take the form of a multipart/form-data with the following key / values:

file
The first key in the form-data body should be named "file", and the value should be the file you're attempting to upload to Decoo.

decooMetadata (Optional)

You can also include some metadata when pinning content to Decoo cloud. The metadata can later be used for easy querying on what you've pinned with pinList request.

decooMetadata takes following form:

{
"name": "<A custom name. If not provided, the original name of the content (if feasible) will be used.>"
}

An example decooMetadata is like below:

"decooOptions": {
"name": "My File"
}

cid

IPFS CID of the file to upload. There are mutltiple approaches to get a file's IPFS CID. For example:

  • IPFS Desktop. User could install IPFS Desktop or go-ipfs locally, and call local IPFS node's /api/v0/add HTTP API to get file CIDs (Note: When calling this API, it's suggested to set only-hash parameter value as true).
  • ipfs-core. Using ipfs-core go get a file's CID.
  • Decoo SDK. Directly use Decoo SDK to get a file's CID.

secret

Users could use their RSA private keys to encrypt file CID to generate digital secret. For more information, please refer to related sections of Pinning with API.

Response#

{
"PinHash": "<This is the Ipfs multi-hash provided back for your file>",
"PinSize": "<This is the size (in bytes) of the pinned content>",
"PinDate": "<This is the timestamp for your content pinning (represented in ISO 8601 format)>"
}

Curl Example#

curl -X POST "https://api-hk.decoo.io/pinning/pinFile" \
-H "UserAccessToken: <YOUR_ACCESS_TOKEN>" \
-H "Content-Type: multipart/form-data" \
-F "[email protected]<YOUR_FILE_PATH>" \
-F 'decooMetadata="{\"name\": \"My File\"}"' \
-F "cid=<YOUR_FILE_CID>" \
-F "secret=<YOUR_DIGITAL_SIGNATURE>"