@@ -15,13 +15,14 @@ import (
15
15
)
16
16
17
17
var (
18
- AccountID = os .Getenv ("STREAM_ACCOUNT" ) // replace with your Cloudflare account ID
19
- API_KEY = os .Getenv ("STREAM_API_KEY" ) // replace with your Cloudflare API key
18
+ AccountID = os .Getenv ("STREAM_ACCOUNT" ) // replace with your Cloudflare account ID
19
+ API_KEY = os .Getenv ("STREAM_API_KEY" ) // replace with your Cloudflare API key
20
+ ENDPOINT_OVERRIDE = os .Getenv ("CLOUDFLARE_URL" ) // optional endpoint override for upload destination
20
21
)
21
22
22
23
var (
23
24
ChunkSize = int64 (5 ) * 1024 * 1024 // 5MB
24
- CloudflareURL = fmt .Sprintf ("https://api.staging. cloudflare.com/client/v4/accounts/%s/stream" , AccountID )
25
+ CloudflareURL = fmt .Sprintf ("https://api.cloudflare.com/client/v4/accounts/%s/stream" , AccountID )
25
26
CloudflareAuth = fmt .Sprintf ("Bearer %s" , API_KEY )
26
27
)
27
28
@@ -68,9 +69,19 @@ func initUpload(filePath string) {
68
69
}
69
70
70
71
func createUpload (fileSize int64 , encodedFilename string ) (string , error ) {
71
- req , err := http .NewRequest ("POST" , CloudflareURL , nil )
72
- if err != nil {
73
- return "" , err
72
+
73
+ var req * http.Request
74
+ var err error
75
+ if ENDPOINT_OVERRIDE != "" {
76
+ req , err = http .NewRequest ("POST" , ENDPOINT_OVERRIDE , nil )
77
+ if err != nil {
78
+ return "" , err
79
+ }
80
+ } else {
81
+ req , err = http .NewRequest ("POST" , CloudflareURL , nil )
82
+ if err != nil {
83
+ return "" , err
84
+ }
74
85
}
75
86
76
87
req .Header .Set ("Content-Type" , "application/offset+octet-stream" )
0 commit comments