Controlling the upload
Uploads created with the chunked uploader can be paused and resumed at any time using the functions
uploader.resume(). For these functions to work, the initial call to
uploader.uploadTransaction() must not be preceded with the
To resume an upload from a new uploader instance, you must use the same:
- Input data
- Configured chunk size
const irys = await getIrys(); // When uploading smaller files, it's common to use the await keyword before // uploadData() or uploadTransaction(). This causes execution to pause until the file // is fully uploaded. If you omit await, the upload happens in the background // and you can use pause and resume as needed. transaction = irys.createTransaction("Hello, world!"); uploader = irys.uploader.chunkedUploader; // recreate for each transaction const upload = uploader.uploadTransaction(transaction); uploader.pause(); // pauses the upload console.log("Upload paused"); uploader.resume(); // resumes the upload console.log("Upload resumed");
While the initial call to
uploader.uploadTransaction() should not use the
await keyword, you can use it down the line to ensure the upload has completed.
You can call await at ANY TIME to ensure the upload has completed.
response = await upload;