use of io.minio.errors.NoResponseException in project runelite by runelite.
the class CacheUploader method run.
@Override
public void run() {
byte[] hash = Hashing.sha256().hashBytes(data).asBytes();
String hashStr = BaseEncoding.base16().encode(hash);
archive.setHash(hash);
String path = new StringBuilder().append(hashStr.substring(0, 2)).append('/').append(hashStr.substring(2)).toString();
try {
try (InputStream in = minioClient.getObject(minioBucket, path)) {
// already exists
return;
} catch (ErrorResponseException ex) {
// doesn't exist
}
minioClient.putObject(minioBucket, path, new ByteArrayInputStream(data), data.length, "binary/octet-stream");
} catch (ErrorResponseException | InsufficientDataException | InternalException | InvalidArgumentException | InvalidBucketNameException | NoResponseException | IOException | InvalidKeyException | NoSuchAlgorithmException | XmlPullParserException ex) {
logger.warn("unable to upload data to store", ex);
}
}
use of io.minio.errors.NoResponseException in project runelite by runelite.
the class CacheService method getArchive.
/**
* retrieve archive from storage
*
* @param archiveEntry
* @return
*/
public byte[] getArchive(ArchiveEntry archiveEntry) {
String hashStr = BaseEncoding.base16().encode(archiveEntry.getHash());
String path = new StringBuilder().append(hashStr.substring(0, 2)).append('/').append(hashStr.substring(2)).toString();
try (InputStream in = minioClient.getObject(minioBucket, path)) {
return ByteStreams.toByteArray(in);
} catch (InvalidBucketNameException | NoSuchAlgorithmException | InsufficientDataException | IOException | InvalidKeyException | NoResponseException | XmlPullParserException | ErrorResponseException | InternalException | InvalidArgumentException ex) {
log.warn(null, ex);
return null;
}
}
Aggregations