Retrieves the contents of the file.
(ctx context.Context, opts ...FileContentsOpts)
| 7216 | |
| 7217 | // Retrieves the contents of the file. |
| 7218 | func (r *File) Contents(ctx context.Context, opts ...FileContentsOpts) (string, error) { |
| 7219 | if r.contents != nil { |
| 7220 | return *r.contents, nil |
| 7221 | } |
| 7222 | q := r.query.Select("contents") |
| 7223 | for i := len(opts) - 1; i >= 0; i-- { |
| 7224 | // `offsetLines` optional argument |
| 7225 | if !querybuilder.IsZeroValue(opts[i].OffsetLines) { |
| 7226 | q = q.Arg("offsetLines", opts[i].OffsetLines) |
| 7227 | } |
| 7228 | // `limitLines` optional argument |
| 7229 | if !querybuilder.IsZeroValue(opts[i].LimitLines) { |
| 7230 | q = q.Arg("limitLines", opts[i].LimitLines) |
| 7231 | } |
| 7232 | } |
| 7233 | |
| 7234 | var response string |
| 7235 | |
| 7236 | q = q.Bind(&response) |
| 7237 | return response, q.Execute(ctx) |
| 7238 | } |
| 7239 | |
| 7240 | // FileDigestOpts contains options for File.Digest |
| 7241 | type FileDigestOpts struct { |