@@ -10,24 +10,20 @@ import (
1010 "github.com/go-resty/resty/v2"
1111)
1212
13- // Fetcher is an interface that fetches binary data from a URL.
14- type Fetcher interface {
15- FetchFromURL (ctx context.Context , url string ) (body []byte , contentType string , filename string , err error )
16- }
17-
18- type fetcher struct {
13+ // Fetcher is a struct that fetches binary data from a URL.
14+ type Fetcher struct {
1915 httpClient * resty.Client
2016}
2117
22- // NewFetcher creates a new BinaryFetcher instance.
18+ // NewFetcher creates a new Fetcher instance.
2319func NewFetcher () Fetcher {
24- return & fetcher {
20+ return Fetcher {
2521 httpClient : resty .New ().SetRetryCount (3 ),
2622 }
2723}
2824
2925// FetchFromURL fetches binary data from a URL.
30- func (f * fetcher ) FetchFromURL (ctx context.Context , url string ) (body []byte , contentType string , filename string , err error ) {
26+ func (f * Fetcher ) FetchFromURL (ctx context.Context , url string ) (body []byte , contentType string , filename string , err error ) {
3127 if strings .HasPrefix (url , "data:" ) {
3228 return f .convertDataURIToBytes (url )
3329 }
@@ -52,7 +48,7 @@ func (f *fetcher) FetchFromURL(ctx context.Context, url string) (body []byte, co
5248 return
5349}
5450
55- func (f * fetcher ) convertDataURIToBytes (url string ) (b []byte , contentType string , filename string , err error ) {
51+ func (f * Fetcher ) convertDataURIToBytes (url string ) (b []byte , contentType string , filename string , err error ) {
5652 slices := strings .Split (url , "," )
5753 if len (slices ) == 1 {
5854 b , err = base64 .StdEncoding .DecodeString (url )
0 commit comments