| 887 | } |
| 888 | |
| 889 | Result<int64_t> ReadAt(int64_t position, int64_t nbytes, void* out) override { |
| 890 | RETURN_NOT_OK(CheckClosed("read")); |
| 891 | RETURN_NOT_OK(CheckPosition(position, "read")); |
| 892 | |
| 893 | nbytes = std::min(nbytes, content_length_ - position); |
| 894 | if (nbytes == 0) { |
| 895 | return 0; |
| 896 | } |
| 897 | |
| 898 | // Read the desired range of bytes |
| 899 | Http::HttpRange range{position, nbytes}; |
| 900 | Storage::Blobs::DownloadBlobToOptions download_options; |
| 901 | download_options.Range = range; |
| 902 | try { |
| 903 | return blob_client_ |
| 904 | ->DownloadTo(reinterpret_cast<uint8_t*>(out), nbytes, download_options) |
| 905 | .Value.ContentRange.Length.Value(); |
| 906 | } catch (const Core::RequestFailedException& exception) { |
| 907 | return ExceptionToStatus( |
| 908 | exception, "DownloadTo from '", blob_client_->GetUrl(), "' at position ", |
| 909 | position, " for ", nbytes, |
| 910 | " bytes failed. ReadAt failed to read the required byte range."); |
| 911 | } |
| 912 | } |
| 913 | |
| 914 | Result<std::shared_ptr<Buffer>> ReadAt(int64_t position, int64_t nbytes) override { |
| 915 | RETURN_NOT_OK(CheckClosed("read")); |
nothing calls this directly
no test coverage detected