| 805 | content_length_(size) {} |
| 806 | |
| 807 | Status Init() { |
| 808 | if (content_length_ != kNoSize) { |
| 809 | // When the user provides the file size we don't validate that its a file. This is |
| 810 | // only a read so its not a big deal if the user makes a mistake. |
| 811 | DCHECK_GE(content_length_, 0); |
| 812 | return Status::OK(); |
| 813 | } |
| 814 | try { |
| 815 | // To open an ObjectInputFile the Blob must exist and it must not represent |
| 816 | // a directory. Additionally we need to know the file size. |
| 817 | auto properties = blob_client_->GetProperties(); |
| 818 | if (MetadataIndicatesIsDirectory(properties.Value.Metadata)) { |
| 819 | return NotAFile(location_); |
| 820 | } |
| 821 | content_length_ = properties.Value.BlobSize; |
| 822 | metadata_ = PropertiesToMetadata(properties.Value); |
| 823 | return Status::OK(); |
| 824 | } catch (const Core::RequestFailedException& exception) { |
| 825 | if (exception.StatusCode == Http::HttpStatusCode::NotFound) { |
| 826 | return PathNotFound(location_); |
| 827 | } |
| 828 | return ExceptionToStatus( |
| 829 | exception, "GetProperties failed for '", blob_client_->GetUrl(), |
| 830 | "'. Cannot initialise an ObjectInputFile without knowing the file size."); |
| 831 | } |
| 832 | } |
| 833 | |
| 834 | Status CheckClosed(const char* action) const { |
| 835 | if (closed_) { |
no test coverage detected