-
Notifications
You must be signed in to change notification settings - Fork 61
/
config.go
47 lines (41 loc) · 1.09 KB
/
config.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
package tus
import (
"net/http"
)
// Config provides a way to configure the Client depending on your needs.
type Config struct {
// ChunkSize divide the file into chunks.
ChunkSize int64
// Resume enables resumable upload.
Resume bool
// OverridePatchMethod allow to by pass proxies sendind a POST request instead of PATCH.
OverridePatchMethod bool
// Store map an upload's fingerprint with the corresponding upload URL.
// If Resume is true the Store is required.
Store Store
// Set custom header values used in all requests.
Header http.Header
// HTTP Client
HttpClient *http.Client
}
// DefaultConfig return the default Client configuration.
func DefaultConfig() *Config {
return &Config{
ChunkSize: 2 * 1024 * 1024,
Resume: false,
OverridePatchMethod: false,
Store: nil,
Header: make(http.Header),
HttpClient: nil,
}
}
// Validate validates the custom configuration.
func (c *Config) Validate() error {
if c.ChunkSize < 1 {
return ErrChuckSize
}
if c.Resume && c.Store == nil {
return ErrNilStore
}
return nil
}