MCPcopy
hub / github.com/perkeep/perkeep / readerAndSize

Method readerAndSize

pkg/client/upload.go:238–248  ·  view source on GitHub ↗

Figure out the size of the contents. If the size was provided, trust it.

()

Source from the content-addressed store, hash-verified

236// Figure out the size of the contents.
237// If the size was provided, trust it.
238func (h *UploadHandle) readerAndSize() (io.Reader, int64, error) {
239 if h.Size > 0 {
240 return h.Contents, int64(h.Size), nil
241 }
242 var b bytes.Buffer
243 n, err := io.Copy(&b, h.Contents)
244 if err != nil {
245 return nil, 0, err
246 }
247 return &b, n, nil
248}
249
250// Upload uploads a blob, as described by the provided UploadHandle parameters.
251func (c *Client) Upload(ctx context.Context, h *UploadHandle) (*PutResult, error) {

Callers 1

UploadMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected