-
Notifications
You must be signed in to change notification settings - Fork 1
/
client_test.go
66 lines (61 loc) · 1.3 KB
/
client_test.go
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package vercel_blob
import (
"fmt"
"io"
"os"
"testing"
)
func Test_CountFiles(t *testing.T) {
client := NewVercelBlobClient()
allFiles, err := client.List(ListCommandOptions{})
if err != nil {
t.Error(err)
return
} else {
fmt.Println(len(allFiles.Blobs))
}
}
func Test_PutWithRandomSuffix(t *testing.T) {
client := NewVercelBlobClient()
f, _ := os.Open("a.png")
defer f.Close()
file1, err := client.Put(
"vercel_blob_unittest/a.png",
io.Reader(f),
PutCommandOptions{
AddRandomSuffix: true,
//ContentType: "multipart/form-data",
})
if err != nil {
t.Error(err)
return
} else {
fmt.Println(file1.URL)
}
}
func Test_Copy(t *testing.T) {
//https://fetegzn4vw3t5yqf.public.blob.vercel-storage.com/vercel_blob_unittest/a.txt
client := NewVercelBlobClient()
res, err := client.Copy("https://fetegzn4vw3t5yqf.public.blob.vercel-storage.com/vercel_blob_unittest/a.txt",
"vercel_blob_unittest/B.txt",
PutCommandOptions{})
if err != nil {
t.Error(err)
return
} else {
fmt.Println(res.URL)
}
}
func Test_Partial_Download(t *testing.T) {
client := NewVercelBlobClient()
bytes, err := client.Download("vercel_blob_unittest/a.txt",
DownloadCommandOptions{
ByteRange: &Range{0, 4},
})
if err != nil {
t.Error(err)
return
} else {
fmt.Println(string(bytes))
}
}