Use http client from msgraphcore (#1484)
## Description Use http client from msgraphcore instead of the one from net/http as it has preconfigured middleware. ## Type of change <!--- Please check the type of change your PR introduces: ---> - [ ] 🌻 Feature - [ ] 🐛 Bugfix - [ ] 🗺️ Documentation - [ ] 🤖 Test - [ ] 💻 CI/Deployment - [x] 🐹 Trivial/Minor ## Issue(s) <!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. --> * https://github.com/alcionai/corso/issues/581 ## Test Plan <!-- How will this be tested prior to merging.--> - [ ] 💪 Manual - [ ] ⚡ Unit test - [x] 💚 E2E
This commit is contained in:
parent
f114785ebb
commit
1f0338a80d
@ -3,9 +3,10 @@ package onedrive
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
|
||||||
|
msgraphgocore "github.com/microsoftgraph/msgraph-sdk-go-core"
|
||||||
msup "github.com/microsoftgraph/msgraph-sdk-go/drives/item/items/item/createuploadsession"
|
msup "github.com/microsoftgraph/msgraph-sdk-go/drives/item/items/item/createuploadsession"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
@ -51,9 +52,13 @@ func driveItemReader(
|
|||||||
|
|
||||||
downloadURL := item.GetAdditionalData()[downloadURLKey].(*string)
|
downloadURL := item.GetAdditionalData()[downloadURLKey].(*string)
|
||||||
|
|
||||||
// TODO: We should use the `msgraphgocore` http client which has the right
|
clientOptions := msgraphsdk.GetDefaultClientOptions()
|
||||||
// middleware/options configured
|
middlewares := msgraphgocore.GetDefaultMiddlewaresWithOptions(&clientOptions)
|
||||||
resp, err := http.Get(*downloadURL)
|
|
||||||
|
httpClient := msgraphgocore.GetDefaultClient(&clientOptions, middlewares...)
|
||||||
|
httpClient.Timeout = 0 // need infinite timeout for pulling large files
|
||||||
|
|
||||||
|
resp, err := httpClient.Get(*downloadURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, errors.Wrapf(err, "failed to download file from %s", *downloadURL)
|
return nil, nil, errors.Wrapf(err, "failed to download file from %s", *downloadURL)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user