@@ -271,19 +271,22 @@ export class S3FileStorage implements FileStorage {
271
271
}
272
272
273
273
private extractMetadata ( key : string , headers : Headers ) : FileMetadata {
274
- const lastModifiedHeader = headers . get ( 'last-modified' ) ;
275
- const lastModified = lastModifiedHeader ? new Date ( lastModifiedHeader ) . getTime ( ) : Date . now ( ) ;
274
+ const metadataLastModified = headers . get ( 'x-amz-meta-lastModified' ) ;
275
+ const lastModifiedHeader = headers . get ( 'last-modified' ) ! ;
276
+ const lastModified = metadataLastModified ? parseInt ( metadataLastModified ) : new Date ( lastModifiedHeader ) . getTime ( ) ;
276
277
277
- const metadataName = headers . get ( 'x-amz-meta-name' ) || '' ;
278
- const metadataLastModified = headers . get ( 'x-amz-meta-lastModified' ) || '' ;
279
- const metadataType = headers . get ( 'x-amz-meta-type' ) || '' ;
278
+ let name = headers . get ( 'x-amz-meta-name' ) ;
279
+ if ( ! name ) {
280
+ name = key . split ( '/' ) . pop ( ) || key ;
281
+ }
282
+ const type = headers . get ( 'x-amz-meta-type' ) || headers . get ( 'content-type' ) || '' ;
280
283
281
284
return {
282
285
key,
283
- name : metadataName ,
284
- lastModified : parseInt ( metadataLastModified , 10 ) || lastModified ,
285
- type : metadataType ,
286
- size : parseInt ( headers . get ( 'content-length' ) || '0' , 10 ) ,
286
+ name,
287
+ lastModified,
288
+ type,
289
+ size : parseInt ( headers . get ( 'content-length' ) || '0' ) ,
287
290
} ;
288
291
}
289
292
@@ -308,9 +311,6 @@ export class S3FileStorage implements FileStorage {
308
311
type,
309
312
size
310
313
} = this . extractMetadata ( key , initial . headers ) ;
311
-
312
- // Try to get the file name from metadata
313
- const fileName = name || key . split ( '/' ) . pop ( ) || key ;
314
314
315
315
// Store AWS client and key in variables that can be captured by the closure
316
316
const aws = this . aws ;
@@ -369,7 +369,7 @@ export class S3FileStorage implements FileStorage {
369
369
370
370
return new LazyFile (
371
371
lazyContent ,
372
- fileName ,
372
+ name ,
373
373
{
374
374
type,
375
375
lastModified
0 commit comments