File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -94,7 +94,7 @@ const uploadTask = job.tasks.filter(task => task.name === 'upload-my-file')[0];
9494
9595const inputFile = fs .createReadStream (' ./file.pdf' );
9696
97- await cloudConvert .tasks .upload (uploadTask, inputFile);
97+ await cloudConvert .tasks .upload (uploadTask, inputFile, ' file.pdf ' );
9898```
9999
100100## Websocket Events
Original file line number Diff line number Diff line change @@ -416,7 +416,11 @@ export default class TasksResource {
416416 await this . cloudConvert . axios . delete ( 'tasks/' + id ) ;
417417 }
418418
419- async upload ( task : Task | JobTask , stream : Stream ) : Promise < any > {
419+ async upload (
420+ task : Task | JobTask ,
421+ stream : Stream ,
422+ filename : string | null = null
423+ ) : Promise < any > {
420424 if ( task . operation !== 'import/upload' ) {
421425 throw new Error ( 'The task operation is not import/upload' ) ;
422426 }
@@ -431,7 +435,11 @@ export default class TasksResource {
431435 formData . append ( parameter , task . result . form . parameters [ parameter ] ) ;
432436 }
433437
434- formData . append ( 'file' , stream ) ;
438+ let fileOptions = { } ;
439+ if ( filename ) {
440+ fileOptions = { filename } ;
441+ }
442+ formData . append ( 'file' , stream , fileOptions ) ;
435443
436444 return await this . cloudConvert . axios . post (
437445 task . result . form . url ,
You can’t perform that action at this time.
0 commit comments