MCPcopy Index your code
hub / github.com/dearcode/candy / FileExist

Method FileExist

client/candy.go:279–295  ·  view source on GitHub ↗

FileExist 判断文件是否存在

(key string)

Source from the content-addressed store, hash-verified

277
278// FileExist 判断文件是否存在
279func (c *CandyClient) FileExist(key string) (bool, error) {
280 req := &meta.GateCheckFileRequest{Names: []string{key}}
281 resp, err := c.api.CheckFile(context.Background(), req)
282 if err != nil {
283 return false, err
284 }
285
286 if err = resp.Header.Error(); err != nil {
287 return false, err
288 }
289
290 if len(resp.Names) == 0 {
291 return true, nil
292 }
293
294 return false, resp.Header.Error()
295}
296
297// FileUpload 文件上传
298func (c *CandyClient) FileUpload(data []byte) (string, error) {

Callers 2

FileUploadMethod · 0.95

Calls 2

CheckFileMethod · 0.65
ErrorMethod · 0.45

Tested by 1