protomaps / go-pmtiles

Single-file executable tool for working with PMTiles archives
https://docs.protomaps.com/pmtiles/cli
BSD 3-Clause "New" or "Revised" License
388 stars 51 forks source link

ensure slashes work in pmtiles serve #59

Open bdon opened 1 year ago

ebbishop commented 1 year ago

This may be relevant: I have a directory tiles with a single archive, test.pmtiles. Running pmtiles serve . --cors=\* from within that directory does allow me to access tiles at localhost:8080/test/z/x/y.mvt. localhost:8080/test/metadata also gives the expected response.

However, running pmtiles serve /full/path/to/tiles --cors=\* results in the following error:

2023/11/01 09:41:14 server.go:124: failed to fetch test 0-0, blob (key "test.pmtiles") 
(code=NotFound): stat /full/path/to/tiles/full/path/to/tiles/test.pmtiles: no such file or directory

Note that the full path to the tiles directory is repeated. localhost:8080/test/metadata returns the response Archive not found.

bdon commented 1 year ago

Here's a way to work around it for now:

go run main.go serve . --bucket=file:///full/path/to/folder

The "bucket" is a path like file:// or s3:// while the . is the prefix within that bucket. Right now the way the local file paths work is consistent with remote buckets. We could add some sugar to detect the local-paths case to make it more intuitive?