Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add API call to download one file #210

Open
wonder-sk opened this issue Jul 18, 2024 · 1 comment
Open

Add API call to download one file #210

wonder-sk opened this issue Jul 18, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@wonder-sk
Copy link
Contributor

Currently, there's no simple way to fetch just one file from a project. There is download_file() API call, but it needs the project to be already downloaded (it is useful just to get older versions of a file).

One could either query MM server API directly, e.g.:

https://app.merginmaps.com/v1/project/raw/<workspace>/<project>?file=myfile.gpkg

(with appropriate auth token)

Alternatively, using python with a workaround like this (handles auth stuff):

from mergin import MerginClient
from mergin.utils import save_to_file

mergin_client = MerginClient(...)
res = mergin_client.get('/v1/project/raw/<workspace>/<project>', data={'file': 'myfile.gpkg'})
save_to_file(res, 'myfile.gpkg')

If we add support for this, maybe we could just update the existing download_file() implementation so that it will accept as the first argument either <workspace>/<project> or it would accept an existing the local directory with a project downloaded already.

@wonder-sk wonder-sk added the enhancement New feature or request label Jul 18, 2024
@MarcelGeo
Copy link
Contributor

MarcelGeo commented Dec 5, 2024

Yeah, this will be useful. There is problem if you call download_file , metadata of project must be there ... you have to call download_project before (:-O) . I think we need to update download_file method to accept project_id instead project_dir . Or create separated method to download file based on project path / id without need to get project_info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants