Я пытаюсь извлечь объект из ведра с помощью openPrefetchingReadChannelGCSInputChannel
. Как Google developer tutorial says
:openPrefetchingReadChannel не работает в API клиента облачного хранилища Google
GcsInputChannel readChannel = gcsService.openPrefetchingReadChannel(fileName, 0, 1024 * 1024);
Prefetching provides is a major performance advantage for most applications, because it
allows processing part of the file while more data is being downloaded in the background
in parallel.The third parameter is the size of the prefetch buffer, set in the example
to 1 megabyte.
Ну, это не для меня. Пожалуйста, посмотрите на мой сниппет:
GcsInputChannel readChannel = gcsService.openPrefetchingReadChannel(fileName, 0, 1024);
copy(Channels.newInputStream(readChannel), resp.getOutputStream());
private void copy(InputStream input, OutputStream output) throws IOException {
try {
byte[] buffer = new byte[BUFFER_SIZE];
int bytesRead = input.read(buffer);
while (bytesRead != -1) {
output.write(buffer, 0, bytesRead);
bytesRead = input.read(buffer);
}
} finally {
input.close();
output.close();
}
}
Приведенный выше код должен доставить 1KB
данных из загруженного объекта, но он возвращает все данные объекта т.е. 8.4KB
. Пожалуйста, посмотрите на скриншот:
Я не уверен, что происходит. Нужна ваша помощь ребятам