add chdir so files are at root of dir

This commit is contained in:
Tyrel Souza 2019-05-16 08:47:19 -04:00
parent bfc0370549
commit 34945e3003
No known key found for this signature in database
GPG Key ID: 5A9394D4C30AEAC0

12
scan.go
View File

@ -15,17 +15,23 @@ func upload(directory string) {
url := fmt.Sprintf("http://127.0.0.1:8000/subscriber/%s/%s/manifest/upload", string(tideliftYML.TeamName), string(tideliftYML.RepositoryName)) url := fmt.Sprintf("http://127.0.0.1:8000/subscriber/%s/%s/manifest/upload", string(tideliftYML.TeamName), string(tideliftYML.RepositoryName))
// TODO: Add revision // TODO: Add revision
var body = map[string]string{ var body = map[string][]string{
// maybe use httpclient.addFormFile and do everything manually... // maybe use httpclient.addFormFile and do everything manually...
// https://github.com/ddliu/go-httpclient/blob/master/httpclient.go#L676 // https://github.com/ddliu/go-httpclient/blob/master/httpclient.go#L676
"@files[]": fileNames[0], // TODO: Add multiple files "@files[]": fileNames,
} }
_, err := httpclient.WithHeaders(map[string]string{ cwd, err := os.Getwd()
check(err)
os.Chdir(directory)
_, err = httpclient.WithHeaders(map[string]string{
"Authorization": auth, "Authorization": auth,
}).Post(url, body) }).Post(url, body)
check(err) check(err)
os.Chdir(cwd)
fmt.Println(body) fmt.Println(body)
} }