use of com.google.common.io.ByteSource in project dhis2-core by dhis2.
the class JCloudsFileResourceContentStore method getFileResourceContent.
// -------------------------------------------------------------------------
// FileResourceContentStore implementation
// -------------------------------------------------------------------------
@Override
public ByteSource getFileResourceContent(String key) {
final Blob blob = getBlob(key);
if (blob == null) {
return null;
}
final ByteSource byteSource = new ByteSource() {
@Override
public InputStream openStream() {
try {
return blob.getPayload().openStream();
} catch (IOException e) {
return new NullInputStream(0);
}
}
};
boolean isEmptyOrFailed;
try {
isEmptyOrFailed = byteSource.isEmpty();
} catch (IOException e) {
isEmptyOrFailed = true;
}
return isEmptyOrFailed ? null : byteSource;
}
Aggregations