MCPcopy Create free account
hub / github.com/OpenListTeam/OpenList / Put

Method Put

drivers/ipfs_api/driver.go:163–182  ·  view source on GitHub ↗
(ctx context.Context, dstDir model.Obj, s model.FileStreamer, up driver.UpdateProgress)

Source from the content-addressed store, hash-verified

161}
162
163func (d *IPFS) Put(ctx context.Context, dstDir model.Obj, s model.FileStreamer, up driver.UpdateProgress) (model.Obj, error) {
164 if d.Mode != "mfs" {
165 return nil, fmt.Errorf("only write in mfs mode")
166 }
167 outHash, err := d.sh.Add(driver.NewLimitedUploadStream(ctx, &driver.ReaderUpdatingProgress{
168 Reader: s,
169 UpdateProgress: up,
170 }))
171 if err != nil {
172 return nil, err
173 }
174 dstPath := path.Join(dstDir.GetPath(), s.GetName())
175 if s.GetExist() != nil {
176 d.sh.FilesRm(ctx, dstPath, true)
177 }
178 err = d.sh.FilesCp(ctx, path.Join("/ipfs/", outHash), dstPath, shell.FilesCp.Parents(true))
179 gateurl := d.gateURL.JoinPath("/ipfs/", outHash)
180 gateurl.RawQuery = "filename=" + url.QueryEscape(s.GetName())
181 return &model.Object{ID: outHash, Name: s.GetName(), Path: dstPath, Size: int64(s.GetSize()), IsFolder: s.IsDir()}, err
182}
183
184//func (d *Template) Other(ctx context.Context, args model.OtherArgs) (interface{}, error) {
185// return nil, errs.NotSupport

Callers

nothing calls this directly

Calls 8

NewLimitedUploadStreamFunction · 0.92
JoinPathMethod · 0.80
AddMethod · 0.65
GetPathMethod · 0.65
GetNameMethod · 0.65
GetExistMethod · 0.65
GetSizeMethod · 0.65
IsDirMethod · 0.65

Tested by

no test coverage detected