| 330 | } |
| 331 | |
| 332 | func DownloadFileWithProxy(url, dst string) error { |
| 333 | resp, cancel, err := req_helper.RequestFile(url, http.MethodGet, constant.TimeOut5m) |
| 334 | if err != nil { |
| 335 | return err |
| 336 | } |
| 337 | defer cancel() |
| 338 | defer resp.Close() |
| 339 | |
| 340 | out, err := os.Create(dst) |
| 341 | if err != nil { |
| 342 | return fmt.Errorf("create download file [%s] error, err %s", dst, err.Error()) |
| 343 | } |
| 344 | defer out.Close() |
| 345 | |
| 346 | if _, err = io.Copy(out, resp); err != nil { |
| 347 | return fmt.Errorf("save download file [%s] error, err %s", dst, err.Error()) |
| 348 | } |
| 349 | return nil |
| 350 | } |
| 351 | |
| 352 | func GetDecoderByName(name string) encoding.Encoding { |
| 353 | switch strings.ToLower(name) { |