radiantearth / stac-api-spec

SpatioTemporal Asset Catalog API specification - an API to make geospatial assets openly searchable and crawlable
http://stacspec.org
Apache License 2.0
213 stars 44 forks source link

How best to serve the assets described in the assets link #198

Closed allanfrankwork closed 3 years ago

allanfrankwork commented 3 years ago

Hi

I have a question on how best to serve the resources pointed to in the assets section of a STAC item. The examples I could find all link outside of the STAC API site itself (for example to s3) but I'd like to keep the STAC API service and the assert download service in the same place/site.

What I'd like to do would be something along the lines of:

https://example.com/v0/collections/collectioname/items/itemid: "assets": { ... "something": { "href": "https://example.com/v0/download/itemid", ...

The /download/ url would simply serve the file with the given itemid. I would expect that this url should be listed in the openAPI spec (Swagger) since its part of the service, but not linked from anywhere else than as an asset since its only interresting for downloading an asset.

Can you see any problems with this approach or is there a better way of doing it? Do you know of any place in the OGC Feature or STAC API spec that restricts what urls a service can have outside of the ones in the spec?

Thanks!

philvarner commented 3 years ago

There are no restrictions on what URLs you can have outside the spec. If I were to do this, I'd go with a more RESTful approach of retrieving an asset by name from:

/collections/{collection_id}/items/{item_id}/assets/{asset_name}

Your example isn't quite complete (unless you only have one asset per item), since "https://example.com/v0/download/itemid" doesn't indicate which of the item's assets you wish to download.

Most services use cloud storage because it's inexpensive and has an HTTP interface that already supports useful features (if you have COGs) like range reads.

philvarner commented 3 years ago

Also, the gitter channel might be a better place for questions like this, since I don't know how many people are actually looking here.

https://gitter.im/SpatioTemporal-Asset-Catalog/Lobby

allanfrankwork commented 3 years ago

I had not considered having the assets served under the item - that is a nice idea. I will consider using this.

In my case I really only have one asset per item so I initially considered serving the asset under

/collections/{collection_id}/items/{item_id}

but with a different content-type and linking the asset there but discarded that idea since the item and the asset are really two different entities. But I agree on your point - with multiple assets using the itemid alone would not work.

Thanks for the suggestion on gitter - I will ask there as well.

Thank you.