Feat: support using SharePoint site to store files

This commit is contained in:
HFO4
2021-03-12 17:05:13 +08:00
parent a54acd71c2
commit 4e2f243436
9 changed files with 196 additions and 29 deletions

View File

@@ -37,14 +37,16 @@ type Endpoints struct {
OAuthEndpoints *oauthEndpoint
EndpointURL string // 接口请求的基URL
isInChina bool // 是否为世纪互联
DriverResource string // 要使用的驱动器
}
// NewClient 根据存储策略获取新的client
func NewClient(policy *model.Policy) (*Client, error) {
client := &Client{
Endpoints: &Endpoints{
OAuthURL: policy.BaseURL,
EndpointURL: policy.Server,
OAuthURL: policy.BaseURL,
EndpointURL: policy.Server,
DriverResource: policy.OptionsSerialized.OdDriver,
},
Credential: &Credential{
RefreshToken: policy.AccessKey,
@@ -56,6 +58,10 @@ func NewClient(policy *model.Policy) (*Client, error) {
Request: request.HTTPClient{},
}
if client.Endpoints.DriverResource == "" {
client.Endpoints.DriverResource = "me/drive"
}
oauthBase := client.getOAuthEndpoint()
if oauthBase == nil {
return nil, ErrAuthEndpoint