Googlecloudstorage custom endpoint subpath removed for upload

Problem

In the Google cloud storage integration there is a problem when specifying a custom endpoint with a subpath, the upload ignores this subpath. For example example.org/custom/endpoint on upload the /custom/endpoint is not reflected.

There is an open issue with the underlying Google storage API go client library which is most likely related.

As this is most likely an issue with the underlying API client, there is no way to fix this in rclone. My suggestion would be to add a hint in the googlecloudstorage docs on that endpoint parameter, that uploads won’t work if the custom endpoint contains paths.

How to reproduce

Running mitmproxy to inspect the requests by rclone.

Set proxy env variables

export HTTP_PROXY="localhost:8080"
export HTTPS_PROXY=$HTTP_PROXY

download

rclone copy -v --gcs-endpoint "example.org/custom/endpoint" --gcs-no-check-bucket --no-check-dest --gcs-bucket-policy-only :gcs:gcs-bucket-name/foo /tmp/foo

In mitmproxy the request contains the subpath :white_check_mark:

GET  example.org/custom/endpoint/storage/v1/b/gcs-bucket-name/o/foo?alt=json&prettyPrint=false

listing

rclone ls  --gcs-endpoint "example.org/custom/endpoint" :gcs:gcs-bucket-name/foo

In mitmproxy the request contains the subpath :white_check_mark:

HTTPS GET example.org/custom/endpoint/storage/v1/b/gcs-bucket-name/o?alt=json&maxResults=1000&prefix=foo%2F&prettyPrint=false

upload

rclone copy -v /tmp/foo --gcs-endpoint "example.org/custom/endpoint" --gcs-no-check-bucket --no-check-dest --gcs-bucket-policy-only :gcs:bucket-name/

In mitmproxy you see the /custom/endpoint part of the custom endpoint is removed. :collision:

HTTPS POST  example.org/upload/storage/v1/b/gcs-bucket-name/o?alt=json&name=foo%2Ffoo&prettyPrint=false&uploadType=multipart

Versions

Reproducible with different rclone versions (with 1.60.0 being the first one to introduce the endpoint parameter on googlecloudstorage)

rclone v1.60.0
- os/version: debian forky/sid (64 bit)
- os/kernel: 6.16.12+deb14+1-amd64 (x86_64)
- os/type: linux
- os/arch: amd64
- go/version: go1.19.2
- go/linking: static
- go/tags: none
rclone v1.69.1
- os/version: debian forky/sid (64 bit)
- os/kernel: 6.16.12+deb14+1-amd64 (x86_64)
- os/type: linux
- os/arch: amd64
- go/version: go1.24.0
- go/linking: static
- go/tags: none
rclone v1.72.0
- os/version: debian forky/sid (64 bit)
- os/kernel: 6.16.12+deb14+1-amd64 (x86_64)
- os/type: linux
- os/arch: amd64
- go/version: go1.25.4
- go/linking: dynamic
- go/tags: cmount

Which cloud storage system are you using? (e.g. Google Drive)

Google Cloud Storage

That is annoying and as it is in the generated part of the code it will be annoying to fix.

However they do take pull requests (apparently I got two merged 11 years ago now!). Not sure what the fix is, but it will probably be something quite simple in the generator.

Do you want to make a pull request for this?

The best change would likely be in the help for endpoint

(This gets put into the docs automatically)

Do you want to make a pull request for this?

Sure!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.