MCPcopy Create free account
hub / github.com/LagrangeDev/LagrangeGo / NewStreamImage

Function NewStreamImage

message/elements.go:245–259  ·  view source on GitHub ↗
(r io.ReadSeeker, summary ...string)

Source from the content-addressed store, hash-verified

243}
244
245func NewStreamImage(r io.ReadSeeker, summary ...string) *ImageElement {
246 md5, sha1, length := crypto.ComputeMd5AndSha1AndLength(r)
247 return &ImageElement{
248 Size: uint32(length),
249 Summary: func() string {
250 if len(summary) != 0 {
251 return summary[0]
252 }
253 return ""
254 }(),
255 Stream: r,
256 Md5: md5,
257 Sha1: sha1,
258 }
259}
260
261func NewFileImage(path string, summary ...string) (*ImageElement, error) {
262 img, err := os.Open(path)

Callers 2

NewImageFunction · 0.85
NewFileImageFunction · 0.85

Calls 1

Tested by

no test coverage detected