Upload files to CloudConvert
masterTo upload files, first create a job with an import/upload task. Then, use the cloudConvert.tasks.upload() method to stream the file to that task.
Note on custom streams:
The SDK automatically detects the file size for file-based read streams. If you are using a custom stream where the length is not known, you must pass the fileSize as the fourth parameter to the upload() method.
const job = await cloudConvert.jobs.create({
tasks: {
'upload-my-file': {
operation: 'import/upload'
}
// ...
}
});
const uploadTask = job.tasks.find(task => task.name === 'upload-my-file');
const inputFile = fs.createReadStream('./file.pdf');
await cloudConvert.tasks.upload(uploadTask, inputFile, 'file.pdf');