add content-length to file upload

This commit is contained in:
Matthew Hooker 2017-06-12 15:01:19 -07:00
parent a1747c21f7
commit 519256feb0
No known key found for this signature in database
GPG Key ID: 7B5F933D9CE8C6A1
1 changed files with 7 additions and 0 deletions

View File

@ -108,6 +108,12 @@ func (v VagrantCloudClient) Upload(path string, url string) (*http.Response, err
return nil, fmt.Errorf("Error opening file for upload: %s", err)
}
fi, err := file.Stat()
if err != nil {
return nil, fmt.Errorf("Error stating file for upload: %s", err)
}
defer file.Close()
request, err := http.NewRequest("PUT", url, file)
@ -118,6 +124,7 @@ func (v VagrantCloudClient) Upload(path string, url string) (*http.Response, err
log.Printf("Post-Processor Vagrant Cloud API Upload: %s %s", path, url)
request.ContentLength = fi.Size()
resp, err := v.client.Do(request)
log.Printf("Post-Processor Vagrant Cloud Upload Response: \n\n%+v", resp)