NodeJS SDK
Installation
Usage
Uploader
const Uploader = require("/path/to/sdk/newfang_uploader").default;
// Generate convergence depending on the use case of your application
const convergence = Uploader.generate_convergence();
// Create an instance of the Uploader object and pass in the absolute path
// to your file and the convergence
const uploader = new Uploader({
filePath: "/path/to/your/file",
convergence
});
// Subscribe to the 'error' event and wrap it around your error handling
uploader.on("error", (e) => {
console.log(e);
// Error. Do something.
});
// Subscribe to the 'progress' event and inform your view
uploader.on("upload_progress", (percentage) => {
console.log("upload progress: ", percentage + "%");
});
// Subscribe to the 'complete' event and wrap your completion handler code
// URI is the identifier for the uploaded file and the only way to access it
uploader.on("upload_complete", (uri) => {
console.log({ uri });
// Upload complete. Do something.
});
// Subscribe to all events before calling start
uploader.start_upload();Downloader
Delete
Remember
Contributing
License
Last updated
Was this helpful?