/add
Description
Using the add method allows you add a single file.
Sample Upload Request using add
For the precheck method project_id
, asset_it
, item_id
, and file
are REQUIRED. Server side validation will reject the request for any of the following:
Parameters do not conform to the UUID Spec
asset_id
already exists - Must be entirely uniqueMissing any of the required parameters
API Key is missing or transmitted improperly
File not in the allowable file types [ 'png', 'jpg', 'jpeg', 'gif', 'bmp', 'mp4', 'json' ]
File is larger than 25 MB in size. (Limits can be increased based on use case and require your account to be upgraded)
var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer <YOUR_API_TOKEN>");
var formdata = new FormData();
formdata.append("project_id", "<CLIENT_GENERATED_UUID>");
formdata.append("asset_id", "<CLIENT_GENERATED_UNIQUE_UUID>");
formdata.append("item_id", "<CLIENT_GENERATED_UUID>");
formdata.append("file", "<FILE_DATA>");
//There are many ways to get the file into the request, whether it be a direct file read via a path, or using a file upload form input. We recommend using a simple file upload input
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: formdata,
redirect: 'follow'
};
fetch("https://ipfs.ordo.so/api/v1/ipfs/add", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
Successful add Response
The response will include a data parameter in the response that contains the full url record locater for your file. This url should be stored client side in order to reference your file.
{
"success": true,
"data": "https://ipfs.ordo.so/api/v1/ipfs/DBTIzZmZGEyLzAwMDAyOWY5LTdlUxOGFhYzQ3Zg==",
"message": "New Record created. File successfully uploaded.",
"errors": []
}
Sample Failed add Response
A failed response on a precheck is almost always due the system not being able to find a similar record. The item_id
parameter is what is used to match to a pre-existing file. If you send a request with an item_id
that has already been used within your project, it will always create a new record linked to the file of the previously uploaded record.
{
"success": false,
"data": null,
"message": "No similar record found, file upload necessary to create record.",
"errors": [],
"upload_required": true
}
Last updated