MCPcopy
hub / github.com/perkeep/perkeep / BlobFromReader

Function BlobFromReader

pkg/schema/schema.go:328–339  ·  view source on GitHub ↗

BlobFromReader returns a new Blob from the provided Reader r, which should be the body of the provided blobref. Note: the hash checksum is not verified.

(ref blob.Ref, r io.Reader)

Source from the content-addressed store, hash-verified

326// which should be the body of the provided blobref.
327// Note: the hash checksum is not verified.
328func BlobFromReader(ref blob.Ref, r io.Reader) (*Blob, error) {
329 if !ref.Valid() {
330 return nil, errors.New("schema.BlobFromReader: invalid blobref")
331 }
332 var buf bytes.Buffer
333 tee := io.TeeReader(r, &buf)
334 ss, err := parseSuperset(tee)
335 if err != nil {
336 return nil, fmt.Errorf("error parsing Blob %v: %w", ref, err)
337 }
338 return &Blob{ref, buf.String(), ss}, nil
339}
340
341// BytesPart is the type representing one of the "parts" in a "file"
342// or "bytes" JSON schema.

Callers 15

FetchSchemaBlobMethod · 0.92
NewFromShareRootFunction · 0.92
isSchemaPickerFunction · 0.92
ReceiveBlobMethod · 0.92
bufferIsCamliJSONMethod · 0.92
handleGetViaSharingMethod · 0.92
bytesHaveSchemaLinkFunction · 0.92
cachedMethod · 0.92
dirInfoMethod · 0.92
fileInfoMethod · 0.92
checkFilesMethod · 0.92
fetchSchemaMetaMethod · 0.92

Calls 3

parseSupersetFunction · 0.85
ValidMethod · 0.45
StringMethod · 0.45

Tested by 3

TestBlobFromReaderFunction · 0.68
TestShareExpirationFunction · 0.68
TestIssue305Function · 0.68