googleapis / googleapis/google-api-go-client

Path replacement of endpoint in Drive /upload operation

Open
#2,623 3 comments 0 reactions 0 assignees View on GitHub
priority: p3 type: question
Dominant language
Go
Stars
4.5k
Forks
1.5k
Avg merge
1d 15h
Merged PRs (30d)
32

Description

When we create a service **with endpoint** ([option#WithEndpoint](https://pkg.go.dev/google.golang.org/api/option#WithEndpoint)) using host and path, ie:
`https://myhost.com/connections/google/`

```go
service, err := drive.NewService(ctx, option.WithHTTPClient(client))
...
tokenSource := option.WithTokenSource(oauth2.StaticTokenSource(&oauth2.Token{AccessToken: *token}))
endpointOptions := option.WithEndpoint("https://myhost.com/connections/google/")
options := []option.ClientOption{
tokenSource,
endpointOptions,
}
```

it works well for operations like folder creation, as the URL will replaced by:
`https://myhost.com/connections/google/files`
Replaced by: https://github.com/googleapis/google-api-go-client/blob/007774894a48d24634ace7b9e09def4d61433f7f/drive/v3/drive-gen.go#L5520

But for media upload operations, like file creation, it is removing our endpoint path here:
https://github.com/googleapis/google-api-go-client/blob/007774894a48d24634ace7b9e09def4d61433f7f/drive/v3/drive-gen.go#L5522

Instead of calling this:
`https://myhost.com/connections/google/upload/drive/v3/files`
it's calling:
`https://myhost.com/upload/drive/v3/files`

The reason is the slash `/` at the beggining of the `relstr` during the `googleapi.ResolveRelative` func call.
This is the only operation that starts with slash, all others (like _files_, _comments_, etc) are appended to our custom endpoint.

Is it an issue or intentional?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.