use of com.microsoft.azure.storage.blob.DownloadResponse in project geowebcache by GeoWebCache.
the class AzureClient method getBytes.
@Nullable
public byte[] getBytes(String key) throws StorageException {
BlockBlobURL blob = getBlockBlobURL(key);
try {
DownloadResponse response = blob.download().blockingGet();
ByteBuffer buffer = FlowableUtil.collectBytesInBuffer(response.body(null)).blockingGet();
byte[] result = new byte[buffer.remaining()];
buffer.get(result);
return result;
} catch (RestException e) {
if (e.response().statusCode() == 404) {
return null;
}
throw new StorageException("Failed to retreive bytes for " + key, e);
}
}
use of com.microsoft.azure.storage.blob.DownloadResponse in project geowebcache by GeoWebCache.
the class AzureBlobStore method get.
@Override
public boolean get(TileObject obj) throws StorageException {
final String key = keyBuilder.forTile(obj);
final BlockBlobURL blob = client.getBlockBlobURL(key);
try {
DownloadResponse response = blob.download().blockingGet();
ByteBuffer buffer = FlowableUtil.collectBytesInBuffer(response.body(null)).blockingGet();
byte[] bytes = new byte[buffer.remaining()];
buffer.get(bytes);
obj.setBlobSize(bytes.length);
obj.setBlob(new ByteArrayResource(bytes));
obj.setCreated(response.headers().lastModified().toEpochSecond() * 1000l);
} catch (RestException e) {
if (e.response().statusCode() == 404) {
return false;
}
throw new StorageException("Error getting " + key, e);
}
return true;
}
Aggregations