@ -60,10 +60,15 @@ public class S3ResourceRepository extends BaseResourceRepository {
GetObjectRequest request = new GetObjectRequest ( bucket , path ) ;
GetObjectRequest request = new GetObjectRequest ( bucket , path ) ;
try {
try {
S3Object s3Object = s3 . getObject ( request ) ;
S3Object s3Object = s3 . getObject ( request ) ;
try {
return s3Object2FileEntry ( s3Object , path ) ;
return s3Object2FileEntry ( s3Object , path ) ;
} finally {
s3Object . close ( ) ;
}
} catch ( Exception e ) {
} catch ( Exception e ) {
LogKit . info ( "{} not exist!" , path ) ;
LogKit . info ( "{} not exist!" , path ) ;
}
}
return null ;
return null ;
}
}
@ -116,7 +121,12 @@ public class S3ResourceRepository extends BaseResourceRepository {
public InputStream read ( String filePath ) throws ResourceIOException {
public InputStream read ( String filePath ) throws ResourceIOException {
GetObjectRequest request = new GetObjectRequest ( bucket , filePath ) ;
GetObjectRequest request = new GetObjectRequest ( bucket , filePath ) ;
try {
try {
return s3 . getObject ( request ) . getObjectContent ( ) ;
S3Object s3Object = s3 . getObject ( request ) ;
try {
return s3Object . getObjectContent ( ) ;
} finally {
s3Object . close ( ) ;
}
} catch ( Exception e ) {
} catch ( Exception e ) {
return new ByteArrayInputStream ( new byte [ 0 ] ) ;
return new ByteArrayInputStream ( new byte [ 0 ] ) ;
}
}
@ -234,20 +244,38 @@ public class S3ResourceRepository extends BaseResourceRepository {
@Override
@Override
public long lastModified ( String path ) {
public long lastModified ( String path ) {
try {
S3Object s3Object = s3 . getObject ( bucket , path ) ;
S3Object s3Object = s3 . getObject ( bucket , path ) ;
if ( s3Object = = null ) {
if ( s3Object ! = null ) {
return - 1L ;
try {
}
return s3Object . getObjectMetadata ( ) . getLastModified ( ) . getTime ( ) ;
return s3Object . getObjectMetadata ( ) . getLastModified ( ) . getTime ( ) ;
} finally {
s3Object . close ( ) ;
}
}
} catch ( Exception e ) {
LogKit . info ( "{} not exist!" , path ) ;
}
return - 1L ;
}
}
@Override
@Override
public long length ( String path ) {
public long length ( String path ) {
try {
S3Object s3Object = s3 . getObject ( bucket , path ) ;
S3Object s3Object = s3 . getObject ( bucket , path ) ;
if ( s3Object = = null ) {
if ( s3Object ! = null ) {
return - 1L ;
try {
}
return s3Object . getObjectMetadata ( ) . getContentLength ( ) ;
return s3Object . getObjectMetadata ( ) . getContentLength ( ) ;
} finally {
s3Object . close ( ) ;
}
}
} catch ( Exception e ) {
LogKit . info ( "{} not exist!" , path ) ;
}
return - 1L ;
}
}
@Override
@Override