File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -93,7 +93,7 @@ const uploadTask = job.tasks.filter(task => task.name === 'upload-my-file')[0];
9393
9494const inputFile = fs .createReadStream (' ./file.pdf' );
9595
96- await cloudConvert .tasks .upload (uploadTask, inputFile);
96+ await cloudConvert .tasks .upload (uploadTask, inputFile, ' file.pdf ' );
9797```
9898
9999
Original file line number Diff line number Diff line change @@ -360,7 +360,7 @@ export default class TasksResource {
360360 await this . cloudConvert . axios . delete ( 'tasks/' + id ) ;
361361 }
362362
363- async upload ( task : Task | JobTask , stream : Stream ) : Promise < any > {
363+ async upload ( task : Task | JobTask , stream : Stream , filename : string | null = null ) : Promise < any > {
364364
365365 if ( task . operation !== 'import/upload' ) {
366366 throw new Error ( 'The task operation is not import/upload' ) ;
@@ -376,7 +376,11 @@ export default class TasksResource {
376376 formData . append ( parameter , task . result . form . parameters [ parameter ] ) ;
377377 }
378378
379- formData . append ( "file" , stream ) ;
379+ let fileOptions = { } ;
380+ if ( filename ) {
381+ fileOptions = { filename : filename } ;
382+ }
383+ formData . append ( "file" , stream , fileOptions ) ;
380384
381385 return await this . cloudConvert . axios . post ( task . result . form . url , formData , {
382386 headers : {
You can’t perform that action at this time.
0 commit comments