-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.go
More file actions
49 lines (41 loc) · 925 Bytes
/
main.go
File metadata and controls
49 lines (41 loc) · 925 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
38
39
40
41
42
43
44
45
46
47
48
49
package main
import (
"fmt"
"os"
"github.com/meowgorithm/pipedream"
)
func main() {
m := pipedream.MultipartUpload{
AccessKey: os.Getenv("ACCESS_KEY"),
SecretKey: os.Getenv("SECRET_KEY"),
Endpoint: "sfo2.digitaloceanspaces.com", // you could use Region for AWS
Bucket: "my-fave-bucket",
}
// Get an io.Reader
f, err := os.Open("big-redis-dump.rdb")
if err != nil {
fmt.Printf("Rats: %v\n", err)
os.Exit(1)
}
defer f.Close()
// Send it up! Pipdream returns a channel where you can listen for events.
ch := m.Send(f, "backups/dump.rdb")
done := make(chan struct{})
// Listen for activity. For more detailed reporting, see the docs.
go func() {
for {
e := <-ch
switch e.(type) {
case pipedream.Complete:
fmt.Println("It worked!")
close(done)
return
case pipedream.Error:
fmt.Println("Rats, it didn't work.")
close(done)
return
}
}
}()
<-done
}