Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website

Allowing users to download files


  • Hey guys, question for you. I'm creating some pretty simple dashboards for some users and I'd like to give the users the ability to download some PDF files from their specific dashboards. These PDFs will most likely be some offline reports that we generate for the users and I want them to download them. What are your thoughts on how to go about this? Should I aim to implement it using some Mango components or just try to do something web standard? What is the purpose of the file store in Mango?
    Thanks as always.


  • Its a general purpose area for uploading and downloading files. You can definitely store your documents in there and link to them.

    I believe we were going to add the ability to define your own file stores and set permissions on them. Not sure what happened to that plan.


  • Hi psysak,

    What is the purpose of the file store in Mango?

    This very thing! Well, and other things. Really anything that involves files (note we moved Excel Report templates into filestores, for instance). That will give you permissions control if required. You can see on the /ui/administration/file-stores page the available file stores, or create a new one. Files placed in there can be downloaded with a simple GET for an authenticated user who has permissions to the file store, with something like GET /rest/v2/file-stores/{FILE STORE NAME}/path/in/filestore/to/file.extension (which can be done in an <a/> tag if you know the store and path). There are also endpoints to list files at locations, and to create filestores. The UI doesn't currently support creating a filestore or changing the read/edit permission. But, you can enable swagger and explore the endpoints at /swagger-ui.html (restarting Mango would be required) or the table definition is pretty easy and you could create a file store via the SQL console, like insert into fileStores (storeName, readPermission, writePermission) values ('CustomStore', 'anybody', 'superadmin');

    So any user with the permissions of 'anybody' would be able to download files from there.


  • Hey guys, thanks for the answer. @phildunlap when you say there are endpoints to list files is that usable for dynamic tables? Ie if I add a folder to a file can I have a table on a page which will then auto add that new file to the table?


  • Yes. Somebody else may give a better answer, but assuredly the file store page is just such a dynamic table at the end of the day. You could figure out how to adapt the directives at play there or use the returned file listings in an ng-repeat to have the dynamic table.

    Ie if I add a folder to a file can I have a table on a page which will then auto add that new file to the table?

    Assuming you mean add folder to file store? I'm not sure if there's a file store websocket that you could use to update it live if someone else modified it, if that's what you're asking. I bet @Jared-Wiltshire knows.


  • @psysak You can use the file store browser component, unfortunately there's no attribute to hide the upload/move/delete buttons yet (the file stores were originally admin only and the component was designed for this). If the user doesn't have write permission these buttons will not work however.

    <ma-file-store-browser ng-model="maFileStoreBrowserModel" store="default" disable-edit="true"></ma-file-store-browser>
    

  • @Jared-Wiltshire there isn't a way to pass a specific path to that component is there?


  • There is actually.

    <ma-file-store-browser ng-init="maFileStoreBrowserModel = '/rest/v2/file-stores/default/your-folder-name/'" ng-model="maFileStoreBrowserModel" store="default" disable-edit="true"></ma-file-store-browser>
    

  • Just quickly, in reading ng-model is a form input correct?

    Is there an ng output of any kind from this component that I could look at? There are no docs in either the API or regular documentation sections for it.


  • @psysak said in Allowing users to download files:

    Just quickly, in reading ng-model is a form input correct?

    ng-model defines the underlying data of a view. Basically in this case the model data is a string which defines the path to a file. If you select a different file in the browser it will update the model variable with the new path.

    @psysak said in Allowing users to download files:

    Is there an ng output of any kind from this component that I could look at?

    I don't know what a ng output is however you can view any variable in your scope like so

    <pre ng-bind="maFileStoreBrowserModel | json"></pre>
    

    @psysak said in Allowing users to download files:

    There are no docs in either the API or regular documentation sections for it.

    Correct, this component was not originally intended for customer use.


  • Quick question, permissions can't be set on a folder in a filestore can they?


  • No permissions are per file store.


  • Hey guys, I was wondering if I could get your help on this a little bit. In light of not being able to lock down individual files is there any other way, either in mango or through the use of the Angular framework or anything else, which would allow me to implement a file download? Main thing is I need to basically lock a user out from easily getting to other people's files.
    I suppose let me ask a different question as well. Will mango have an issue if I create a hundred filestores? I'm not sure I'll need 100 but let's say I did.
    I also do realize I could probably link to an FTP, but that makes a much less seamless experience. I like the file store as well because I can just drop files and they appear. If I had a table or whatever I'd have to traverse a directory and build links dynamically and I'm not great with how to accomplish that.

    Thanks all, I'm a bit up against it here on this one.


  • @psysak said in Allowing users to download files:

    I suppose let me ask a different question as well. Will mango have an issue if I create a hundred filestores? I'm not sure I'll need 100 but let's say I did.

    It should be totally fine to have hundreds of file stores.

    The file stores weren't really intended to be per user but per "group" / "role"


  • OK that's fair, I would consider this implementation an instance of "group/role of one" :)
    Thanks that helps!


  • @phildunlap said in Allowing users to download files:

    This very thing! Well, and other things.

    I chuckled a little too hard on that comment!


  • Hi guys,

    I have a user with only edit-ui-pages role and I have add edit-ui-pages role into flle stores' edit menu page as such:

    5c571a4b-6053-411f-be6a-a6fb13aed5b3-image.png

    However, when I login with the new user, the user can only see the file stores > default directory. The user cannot add files or directory to the default directory. Furthermore, the user cannot access the file stores > public directory. What else do I need to setup so the user can access the file stores' public directory?

    Please advise.

    BR,
    Ricardo


  • Check filestore permissions under
    administration->system-settings->permissions
    for a start.

    Fox