github.com/ravendb/ravendb-go-client@v0.0.0-20240229102137-4474ee7aa0fa/attachment_result.go (about) 1 package ravendb 2 3 import ( 4 "io" 5 "net/http" 6 ) 7 8 // Note: In Java it's CloseableAttachmentResult 9 10 // AttachmentResult represents an attachment 11 type AttachmentResult struct { 12 Data io.Reader 13 Details *AttachmentDetails 14 response *http.Response 15 } 16 17 func newAttachmentResult(response *http.Response, details *AttachmentDetails) *AttachmentResult { 18 return &AttachmentResult{ 19 Data: response.Body, 20 Details: details, 21 response: response, 22 } 23 } 24 25 // Close closes the attachment 26 func (r *AttachmentResult) Close() error { 27 if r.response.Body != nil { 28 return r.response.Body.Close() 29 } 30 return nil 31 }