Skip to content

Path replacement of endpoint in Drive /upload operation #2623

@denisazevedo

Description

@denisazevedo

When we create a service with endpoint (option#WithEndpoint) using host and path, ie:
https://myhost.com/connections/google/

	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:

urls := googleapi.ResolveRelative(c.s.BasePath, "files")

But for media upload operations, like file creation, it is removing our endpoint path here:

urls = googleapi.ResolveRelative(c.s.BasePath, "/upload/drive/v3/files")

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?

Metadata

Metadata

Assignees

Labels

priority: p3Desirable enhancement or fix. May not be included in next release.type: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions