MCPcopy Create free account
hub / github.com/devld/go-drive / CopyReaderToTempFile

Function CopyReaderToTempFile

common/drive_util/utils.go:133–151  ·  view source on GitHub ↗
(ctx types.TaskCtx, reader io.Reader, tempDir string)

Source from the content-addressed store, hash-verified

131}
132
133func CopyReaderToTempFile(ctx types.TaskCtx, reader io.Reader, tempDir string) (*os.File, error) {
134 file, e := os.CreateTemp(tempDir, "drive-copy")
135 if e != nil {
136 return nil, e
137 }
138 _, e = Copy(ctx, file, reader)
139 if e != nil {
140 _ = file.Close()
141 _ = os.Remove(file.Name())
142 return nil, e
143 }
144 _, e = file.Seek(0, 0)
145 if e != nil {
146 _ = file.Close()
147 _ = os.Remove(file.Name())
148 return nil, e
149 }
150 return file, nil
151}
152
153func GetIContentReader(ctx context.Context, content types.IContentReader, start, size int64) (io.ReadCloser, error) {
154 u, e := content.GetURL(ctx)

Callers 2

CopyIContentToTempFileFunction · 0.85

Calls 5

CopyFunction · 0.85
CloseMethod · 0.65
NameMethod · 0.65
RemoveMethod · 0.45
SeekMethod · 0.45

Tested by

no test coverage detected