Fetchfile gets the content of a file from the given offset using a remote reader.
(r reader.Reader, name string, offset int64, count int)
| 24 | |
| 25 | // Fetchfile gets the content of a file from the given offset using a remote reader. |
| 26 | func FetchFile(r reader.Reader, name string, offset int64, count int) ([]byte, error) { |
| 27 | d := make([]byte, count) |
| 28 | l := r.Log().With().Str("name", name).Int64("offset", offset).Int("count", count).Logger() |
| 29 | l.Debug().Msg("fetch file start") |
| 30 | |
| 31 | _, err := r.PreadRemote(d, offset) |
| 32 | if err != nil && err != io.EOF { |
| 33 | l.Error().Err(err).Msg("fetch file error") |
| 34 | return nil, err |
| 35 | } |
| 36 | |
| 37 | l.Debug().Msg("fetch file stop") |
| 38 | return d, nil |
| 39 | } |