Class S3Resource
java.lang.Object
org.craftercms.commons.spring.resources.S3Resource
- All Implemented Interfaces:
RangeAwareResource
,org.springframework.core.io.InputStreamSource
,org.springframework.core.io.Resource
Implementation of
Resource
for S3 files.- Author:
- avasquez
-
Constructor Summary
ConstructorDescriptionS3Resource
(S3ClientCachingFactory clientFactory, S3Profile profile, String key) S3Resource
(S3ClientCachingFactory clientFactory, S3Profile profile, String bucket, String key) -
Method Summary
Modifier and TypeMethodDescriptionlong
org.springframework.core.io.Resource
createRelative
(String relativePath) boolean
exists()
protected String
getFile()
getInputStream
(long start, long end) Returns a range of bytes from the resource's content.getURI()
getURL()
boolean
isOpen()
boolean
long
toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.springframework.core.io.Resource
isFile, readableChannel
-
Constructor Details
-
S3Resource
-
S3Resource
public S3Resource(S3ClientCachingFactory clientFactory, S3Profile profile, String bucket, String key)
-
-
Method Details
-
getActualKey
-
exists
public boolean exists()- Specified by:
exists
in interfaceorg.springframework.core.io.Resource
-
isReadable
public boolean isReadable()- Specified by:
isReadable
in interfaceorg.springframework.core.io.Resource
-
isOpen
public boolean isOpen()- Specified by:
isOpen
in interfaceorg.springframework.core.io.Resource
-
getURL
- Specified by:
getURL
in interfaceorg.springframework.core.io.Resource
- Throws:
IOException
-
getURI
- Specified by:
getURI
in interfaceorg.springframework.core.io.Resource
- Throws:
IOException
-
getFile
- Specified by:
getFile
in interfaceorg.springframework.core.io.Resource
- Throws:
IOException
-
contentLength
- Specified by:
contentLength
in interfaceorg.springframework.core.io.Resource
- Throws:
IOException
-
lastModified
- Specified by:
lastModified
in interfaceorg.springframework.core.io.Resource
- Throws:
IOException
-
createRelative
- Specified by:
createRelative
in interfaceorg.springframework.core.io.Resource
- Throws:
IOException
-
getFilename
- Specified by:
getFilename
in interfaceorg.springframework.core.io.Resource
-
getDescription
- Specified by:
getDescription
in interfaceorg.springframework.core.io.Resource
-
getInputStream
- Specified by:
getInputStream
in interfaceorg.springframework.core.io.InputStreamSource
- Throws:
IOException
-
getInputStream
Description copied from interface:RangeAwareResource
Returns a range of bytes from the resource's content.- Specified by:
getInputStream
in interfaceRangeAwareResource
- Parameters:
start
- the start of the rangeend
- the end of the range- Returns:
- an input stream with the content range
- Throws:
IOException
- if an IO error occurs
-
toString
-