ar.io LogoAr.io Documentation
Turbo SDKEvents

File Upload Events

These events are available for upload, uploadFile, and uploadSignedDataItem methods:

  • onProgress - emitted when the overall progress changes (includes both upload and signing). Each event consists of the total bytes, processed bytes, and the step (upload or signing)
  • onError - emitted when the overall upload or signing fails (includes both upload and signing)
  • onSuccess - emitted when the overall upload or signing succeeds (includes both upload and signing) - this is the last event emitted for the upload or signing process
  • onSigningProgress - emitted when the signing progress changes.
  • onSigningError - emitted when the signing fails.
  • onSigningSuccess - emitted when the signing succeeds
  • onUploadProgress - emitted when the upload progress changes
  • onUploadError - emitted when the upload fails
  • onUploadSuccess - emitted when the upload succeeds
const uploadResult = await turbo.uploadFile({
  fileStreamFactory: () => fs.createReadStream(filePath),
  fileSizeFactory: () => fileSize,
  events: {
    // overall events (includes signing and upload events)
    onProgress: ({ totalBytes, processedBytes, step }) => {
      console.log('Overall progress:', { totalBytes, processedBytes, step });
    },
    onError: ({ error, step }) => {
      console.log('Overall error:', { error, step });
    },
    onSuccess: () => {
      console.log('Overall success!');
    },
    // signing events
    onSigningProgress: ({ totalBytes, processedBytes }) => {
      console.log('Signing progress:', { totalBytes, processedBytes });
    },
    onSigningError: (error) => {
      console.log('Signing error:', { error });
    },
    onSigningSuccess: () => {
      console.log('Signing success!');
    },
    // upload events
    onUploadProgress: ({ totalBytes, processedBytes }) => {
      console.log('Upload progress:', { totalBytes, processedBytes });
    },
    onUploadError: (error) => {
      console.log('Upload error:', { error });
    },
    onUploadSuccess: () => {
      console.log('Upload success!');
    },
  },
});

How is this guide?