-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimgur.go
More file actions
37 lines (31 loc) · 884 Bytes
/
imgur.go
File metadata and controls
37 lines (31 loc) · 884 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package main
import (
"errors"
"fmt"
)
// Sender sends a stream of bytes to a remote system.
type Sender interface {
Send([]byte) error
}
// ImgurClient is an implementation of Sender that can send a stream of bytes to the imgur.com service.
type ImgurClient struct{}
// Send method implements Sender.
func (c ImgurClient) Send([]byte) error {
fmt.Println("[ImgurClient] Sending file...")
return nil
}
// client returns the corresponding Sender according to the service requested.
func client(service string) (Sender, error) {
if service == "gist" {
return GistClient{}, nil
} else if service == "imgur" {
return ImgurClient{}, nil
} else if service == "giphy" {
return GiphyClient{}, nil
}
return nil, errors.New("unknown service")
}
// upload sends a stream of bytes to a Sender.
func upload(client Sender, stream []byte) error {
return client.Send(stream)
}