MCPcopy Create free account
hub / github.com/krau/SaveAny-Bot / WriteFile

Method WriteFile

storage/webdav/client.go:150–167  ·  view source on GitHub ↗
(ctx context.Context, remotePath string, content io.Reader)

Source from the content-addressed store, hash-verified

148}
149
150func (c *Client) WriteFile(ctx context.Context, remotePath string, content io.Reader) error {
151 u, err := url.Parse(c.BaseURL)
152 if err != nil {
153 return err
154 }
155 parts := strings.Split(strings.Trim(remotePath, "/"), "/")
156 u.Path = path.Join(u.Path, strings.Join(parts, "/"))
157 resp, err := c.doRequest(ctx, WebdavMethodPut, u.String(), content)
158 if err != nil {
159 return err
160 }
161 defer resp.Body.Close()
162
163 if resp.StatusCode >= 200 && resp.StatusCode < 300 {
164 return nil
165 }
166 return fmt.Errorf("PUT: %s", resp.Status)
167}
168
169// ListDir lists files and directories in the given path
170func (c *Client) ListDir(ctx context.Context, dirPath string) ([]Response, error) {

Callers 5

TestWriteFileFunction · 0.95
addPluginFunction · 0.80
TestExtractThumbFrameFunction · 0.80
SaveMethod · 0.80
mainFunction · 0.80

Calls 4

doRequestMethod · 0.95
ParseMethod · 0.65
StringMethod · 0.45
CloseMethod · 0.45

Tested by 2

TestWriteFileFunction · 0.76
TestExtractThumbFrameFunction · 0.64