You can easily upload a file to Neucron using the uploadFile function, supporting options such as specifying the file path, data, and wallet ID. In a browser environment, you need to create an input element to handle file selection.
// For browser:constfileInput=document.createElement('input');fileInput.type ='file';fileInput.onchange=async () => {console.log(awaitneucron.dataIntegrity.uploadFile({ filePath:fileInput.files[0] }));};// For Node.js:console.log(awaitneucron.dataIntegrity.uploadFile({ filePath:'path/to/your/file.png' }));
Upload Encrypted File
For enhanced security, use the uploadEncryptFile function to upload an encrypted file. Provide the file path, public key, and an optional wallet ID.
Post Data
Utilize the postData function to post data to Neucron, including a message and an optional wallet ID.
Upload File on Ordinal
Upload a file to a specific ordinal using the uploadFileOnOrdinal function. Specify the file path and an optional wallet ID.
Upload Hashed File
Upload a hashed file with the uploadHashedFile function. Provide the file path and an optional wallet ID.
API Response
Upon successful API calls, you can expect a response in the following format:
data: Contains the specific data returned by the API call.
txid: Transaction ID associated with the operation.
status_code: Indicates the HTTP status code of the response. A status code of 200 signifies a successful request.
Ensure proper handling of the response in your application based on the information provided in the data field, and check the status_code to confirm the success of the operation.
Note: The Neucron SDK is compatible with both Node.js and browser-based environments. Choose the appropriate import statement based on your environment.