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.
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.
This version includes instructions on how to handle file inputs in both browser and Node.js environments. Feel free to adjust as needed.