fix(webdav): adds missing auth headers

closes #6779
This commit is contained in:
bergquist 2016-12-02 16:18:40 +01:00
parent f9fba0e935
commit c17064fb44

View File

@ -7,7 +7,6 @@ import (
"net/http"
"net/url"
"path"
"time"
"github.com/grafana/grafana/pkg/util"
)
@ -19,14 +18,17 @@ type WebdavUploader struct {
}
func (u *WebdavUploader) Upload(pa string) (string, error) {
client := http.Client{Timeout: time.Duration(10 * time.Second)}
url, _ := url.Parse(u.url)
url.Path = path.Join(url.Path, util.GetRandomString(20)+".png")
imgData, err := ioutil.ReadFile(pa)
req, err := http.NewRequest("PUT", url.String(), bytes.NewReader(imgData))
res, err := client.Do(req)
if u.username != "" {
req.SetBasicAuth(u.username, u.password)
}
res, err := http.DefaultClient.Do(req)
if err != nil {
return "", err