FileExist 判断文件是否存在
(key string)
| 277 | |
| 278 | // FileExist 判断文件是否存在 |
| 279 | func (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 文件上传 |
| 298 | func (c *CandyClient) FileUpload(data []byte) (string, error) { |