@Override
public Future<GcsFileMetadata> readObjectAsync(
ByteBuffer dst, GcsFilename filename, long offset, long timeoutMillis) {
Preconditions.checkArgument(offset >= 0, "%s: offset must be non-negative: %s", this, offset);
try {
GcsFileMetadata meta = getObjectMetadata(filename, timeoutMillis);
if (meta == null) {
return Futures.immediateFailedFuture(
new FileNotFoundException(this + ": No such file: " + filename));
}
if (offset >= meta.getLength()) {
return Futures.immediateFailedFuture(new BadRangeException(
"The requested range cannot be satisfied. bytes=" + Long.toString(offset) + "-"
+ Long.toString(offset + dst.remaining()) + " the file is only " + meta.getLength()));
}
AppEngineFile file = nameToAppEngineFile(filename);
try (FileReadChannel readChannel = FILES.openReadChannel(file, false)) {
readChannel.position(offset);
int read = 0;