biothings / biothings_studio

Pre-configured & ready-to-use BioThings API development environment
Apache License 2.0
4 stars 3 forks source link

ngnix could expose a data directory to make external data accessible from the hub #2

Closed sirloon closed 6 years ago

sirloon commented 6 years ago

Scenario: a datasource has a file that needs to be downloaded locally first (login required for instance). When writing the plugin manifest for this source, the local file:// protocol isn't supported, only http, https and ftp. By putting the data file under ngnix, we can define the data_url as http://localhost:8080/data/myfile.zip

sirloon commented 6 years ago

done in https://github.com/biothings/biothings.api/commit/01f1f98c8b481c33c4925ece2dbe2d3906af9bf6 and 73dbc4c2fb1e272785ad549077522a7c636e4323, 7ac84e6859a7f60f945f8bc4449e7241d39f12b5, ab92cba842b998c35ce7e42da5ae8d62f34eb98a

An upload handler was added to the Hub API, and can be access by sending a file like that:

curl -F 'data=@/Users/slelong/data.zip' http://localhost:7080/data/mvcgi

Note the endpoint finishes with mvcgi, the datasource name (or at least the sub-folder in which data.zip will be stored.

Later, that same file can be dumped into the hub through this URL (this times served by ngnix):

http://localhost:8080/data/cgi/data.zip