mirror of https://gitea.com/webb/interrupt
39 lines
477 B
Go
39 lines
477 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
"os"
|
|
)
|
|
|
|
func uploadHandler(a string) {
|
|
uploadKey, err := getUploadKey()
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
os.Exit(1)
|
|
}
|
|
|
|
var reader io.Reader
|
|
|
|
if os.Args[2] == "-" {
|
|
reader = os.Stdin
|
|
} else {
|
|
reader, err = os.Open(a)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
os.Exit(1)
|
|
}
|
|
}
|
|
|
|
itCl.UploadKey = uploadKey
|
|
|
|
r, err := itCl.UploadFile(reader, a)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
os.Exit(1)
|
|
}
|
|
|
|
fmt.Println(r)
|
|
os.Exit(0)
|
|
}
|