@@ -583,26 +583,41 @@ export const copyS3Objects = async (
583
583
registeredFileTypes
584
584
) ;
585
585
586
- // retrieve information of new file
587
- const newFileContents = await s3Client . send (
588
- new GetObjectCommand ( {
589
- Bucket : newBucketName ?? bucketName ,
590
- Key : name + ( suffix ? suffix : '' )
591
- } )
592
- ) ;
586
+ try {
587
+ const newFileContents = await s3Client . send (
588
+ new GetObjectCommand ( {
589
+ Bucket : newBucketName ?? bucketName ,
590
+ Key : name + ( suffix ? suffix : '' )
591
+ } )
592
+ ) ;
593
593
594
- data = {
595
- name : PathExt . basename ( name ) ,
596
- path : name ,
597
- last_modified : newFileContents . LastModified ! . toISOString ( ) ,
598
- created : new Date ( ) . toISOString ( ) ,
599
- content : await newFileContents . Body ! . transformToString ( ) ,
600
- format : fileFormat as Contents . FileFormat ,
601
- mimetype : fileMimeType ,
602
- size : newFileContents . ContentLength ! ,
603
- writable : true ,
604
- type : fileType
605
- } ;
594
+ data = {
595
+ name : PathExt . basename ( name ) ,
596
+ path : name ,
597
+ last_modified : newFileContents . LastModified ! . toISOString ( ) ,
598
+ created : new Date ( ) . toISOString ( ) ,
599
+ content : await newFileContents . Body ! . transformToString ( ) ,
600
+ format : fileFormat as Contents . FileFormat ,
601
+ mimetype : fileMimeType ,
602
+ size : newFileContents . ContentLength ! ,
603
+ writable : true ,
604
+ type : fileType
605
+ } ;
606
+ } catch {
607
+ // object directory itself doesn't exist
608
+ data = {
609
+ name : PathExt . basename ( name ) ,
610
+ path : name ,
611
+ last_modified : new Date ( ) . toISOString ( ) ,
612
+ created : new Date ( ) . toISOString ( ) ,
613
+ content : [ ] ,
614
+ format : fileFormat as Contents . FileFormat ,
615
+ mimetype : fileMimeType ,
616
+ size : 0 ,
617
+ writable : true ,
618
+ type : fileType
619
+ } ;
620
+ }
606
621
607
622
return data ;
608
623
} ;
0 commit comments