ORDO
  • What is ORDO
  • Articles
  • Utility
    • NFT Builder
    • Blueprints
    • Whitelist Management
    • 2FA / Multisig Vaults
    • Autonomous Distribution Contracts
  • Documentation
    • FireNode
      • Getting Started
      • Functions
        • /precheck
        • /add
        • /get
Powered by GitBook
On this page
  • Description
  • Sample Upload Request using Precheck
  • Successful Precheck Response
  • Sample Failed precheck Response
  1. Documentation
  2. FireNode
  3. Functions

/precheck

Description

Using the precheck method allows you to first check if you are creating a new record for an existing file. If the file exists within your project it will create a new record with a new URL that is independent of itself but is linked to the original file saving you storage costs and upload/retrieval times. A file is not required when using this method. If no matching file is found, it will respond back with an upload_required:true in the response. It is recommended that anyone bulk uploading files that have multiples of the same file run each request through the precheck method first.

Sample Upload Request using Precheck

For the precheck method project_id, asset_it, and item_id 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 unique

  • Missing any of the required parameters

  • API Key is missing or transmitted improperly

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>");

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: formdata,
  redirect: 'follow'
};

fetch("https://ipfs.ordo.so/api/v1/ipfs/precheck", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Successful Precheck 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/NS00MmU3LWIzZmZGEyLzAwMDAyOWY5LTdlUxOGFhYzQ3Zg==",
    "message": "Related record using the same file found. New Record created using similar record. No File Upload Neccessary.",
    "errors": [],
    "upload_required": false
}

Sample Failed precheck 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
}
PreviousFunctionsNext/add

Last updated 2 years ago