How to download a file using the API (and login)

I wish to allow users to download a files using the Fibery API and only the files that they have access to. I wish to ask if what I am trying here is possible.

Background:

  • The users can downloads rapports, each belonging to an individual field. Every rapport file is in a separate space, so permissions for each rapport can be given separately. *See note below this post

1. User clicks on a field, a side menu pops up and then the user can download a report for that field by clicking “Download rapport”

2. A login screen appears over the rest if people are not logged in yet (if they are, skip this step)

3. The file is downloaded (provided the user has the necessary permissions to access this file).

It would be awesome if this would work! :blush: Input is very welcome. I will try to solve this puzzle myself, but it’s nice to know in advance if this would be fruitful or not. If I manage to make this, I will share how I did it.


Note: this is a bit of a workaround, one that is good enough for the prototype phase (this phase includes just a few handful fields/rapports). My client has more than 2000 rapports, so managing that using 2000 spaces will be ugly, then it will be really nice to have one Rapports table with 2000+ entities and give permissions for each one.

I’m not sure what this means.
At the moment, files (rapports) can belong to an entity (via the Files field) but are not tied to another specific field.

Or are these ‘fields’ something outside of Fibery?

Downloading files via API is relatively easy to do: Fibery API but the API call requires a token, which the user has to generate in the Fibery workspace himself. AFAIK, it’s not possible to get a request a token with a username and password

Thanks @Chr1sG :facepunch:

Yes I have seen the API docs :ok_hand:

I’m not sure what this means.
At the moment, files (rapports) can belong to an entity (via the Files field) but are not tied to another specific field.

Or are these ‘fields’ something outside of Fibery?

Aah yes, field has a different meaning here! I mean farmers fields! :tractor: Every field’s soil is scanned and the reports document the result of this scan, so what soil characteristics there are. I would make entities for all the different fields and entities for all the different reports and relate them :blush: But that’s more detail then necessary now

Downloading files via API is relatively easy to do: [Fibery API ](https://api.fibery.io/#file) but the API call requires a token, which the user has to generate in the Fibery workspace himself. AFAIK, it’s not possible to get a request a token with a username and password

Check! I will see how I can get users to login and then return to the map. Fun to start using the API, I have many ideas to do more with this so this is a nice way to get started.