From e8291be26125817b4482411a5907ecf4d4cfb079 Mon Sep 17 00:00:00 2001 From: Arran Ubels Date: Wed, 12 Dec 2018 12:24:59 +1100 Subject: [PATCH] SimpleUpload needs to support reader interface for requests I found that this worked for me. --- request.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/request.go b/request.go index 8831857..d035e9e 100644 --- a/request.go +++ b/request.go @@ -41,10 +41,17 @@ func (od *OneDrive) newRequest(method, uri string, requestHeaders map[string]str return nil, errors.New(fmt.Sprintf("you are making too many requests. Please wait: %s", od.throttle.Sub(time.Now()))) } - requestBody, err := createRequestBody(body) - if err != nil { - return nil, err - } + var requestBody io.Reader + + switch b := body.(type) { + case io.Reader: + requestBody = b + default: + var err error + if requestBody, err = createRequestBody(b); err != nil { + return nil, err + } + } req, err := http.NewRequest(method, od.BaseURL+uri, requestBody) if err != nil {