files.go 474 B

12345678910111213141516171819202122232425
  1. package api
  2. import (
  3. "context"
  4. "strconv"
  5. )
  6. var (
  7. downloadHost = "https://files.ente.io/?fileID="
  8. )
  9. func (c *Client) DownloadFile(ctx context.Context, fileID int64, absolutePath string) error {
  10. req := c.downloadClient.R().
  11. SetContext(ctx).
  12. SetOutput(absolutePath)
  13. attachToken(req)
  14. r, err := req.Get(downloadHost + strconv.FormatInt(fileID, 10))
  15. if r.IsError() {
  16. return &ApiError{
  17. StatusCode: r.StatusCode(),
  18. Message: r.String(),
  19. }
  20. }
  21. return err
  22. }