Closed kakaroto closed 2 years ago
Hello, Thanks for the heads up. Unfortunately I don't have an active subscription on Forge so I couldn't test any changes I'd make to the way the Asset folders are currently handled.
I did some optimization a while back which significantly sped things up using a trial account so I at least know that error or no it appears to work. In fear of breaking anything I wont touch the code related to this for now but will keep the advice in mind just in case.
Unfortunately I don't have an active subscription on Forge so I couldn't test any changes I'd make to the way the Asset folders are currently handled.
You might not have been aware of this, but I offer free Forge subscriptions to Foundry module developers, so feel free to poke me on Discord and I'll upgrade you!
In fear of breaking anything I wont touch the code related to this for now
That's a very sensible stance to take :) Thanks for testing things on the Forge by the way. Whether you plan on changing it (with testing) or not, do poke me for that upgrade, regardless.
Thanks!
Thanks again for the subscription!
I just had a look at the code and did some playing around with the FilePicker. I should be able to simplify some of the code but before getting to work I wondered if you knew if there was a way for users to recursively traverse the asset folders of other users?
Some months ago I was requested to add support for the module to source images both from the GM's and one of his player's assets. At the moment the module uses a work around of traversing the GMs asset folder when the world gets loaded and storing the structure in a global setting. e.g.:
game.settings.get("token-variants", "forgevttPaths")
Array(3) [ {…}, {…}, {…} ] 0: Object { text: "https://assets.forge-vtt.com/{gmUserId}/token_art/", cache: true } 1: Object { text: "https://assets.forge-vtt.com/{gmUserId}/token_art/azel/", cache: true } 2: Object { text: "https://assets.forge-vtt.com/{gmUserId}/token_art/chip/", cache: true } length: 3
Wilcard browse is then performed on the players end to retrieve all of the images:
await FilePicker.browse("forgevtt", "https://assets.forge-vtt.com/{gmUserId}/token_art/*", {wildcard: true})
This is... hacky... -.-'
Any chance of doing this a bit more conveniently or it's just a deliberate limitation/security measure and I need to suck it up? :)
Alright did more digging and I guess the appropriate way of handling asset sharing would be via generated API Keys. If it's just providing access to one users assets the rest of the players could simply add their API Key in the Forge settings, but it order for this module to support sharing of multiple user asset folders I will need to manage these keys through the module itself and call the Forge API directly as there is no way of passing the appropriate Access-Key through the FilePicker...
This is bit more involved that I expected and will take some time.
No problem Aedif. As with your other question. The wildcard support does allow a user to find files in another player's game but as a security measure, it does not expose folders, it will not allow a recursive browse and will only work for users who share the same game with each other (i.e: user A can wildcard browse the files in user B's library if they are players in the same game, but can't do it for user C which they have no games in common). It is a security measure and will not change, and using the wildcard that way is not its intended purpose :P
If a user wants to share access to their assets library with someone else, the API key is the way to do it, but that seems really quite extensive like you said, to have a folder + api key so a user can browse the other user's assets for tokens. I don't see a better option though 🤔 Good luck!
Pushed out an update (1.22.0) making use of the 'recursive' flag to no longer require multiple API calls when browsing Forge Asset Libraries.
To facilitate sharing of asset folders between all the player a new setting has been added: Forge Asset Library Paths. Each player is able to configure paths privately for themselves and also expose them to all the player by adding an API Key and flagging each path individualy as Shared or not.
When configured this way image retrieval is far faster that using the hacky wildcard method.
Thanks for the tips kakaroto!
Hi, Someone mentioned your module in our chat today and when I checked it out, I saw it was doing something to recursively list the directories in the assets library of the user. I figured I'd let you know that there our API has an undocumented option you can pass to do the call recusively in a single API query, just pass![image](https://user-images.githubusercontent.com/27990/149505661-e3c27827-2859-4bed-ae76-d2b7611c3b0f.png)
{recursive: true}
to theFilePicker.browse
API.I also noticed that you pass the
https://assets.forge-vtt.com/${userid}
as the source, it should just be "forgevtt" as the source. Thankfully, we fallback on it if the browse results in an error, but it means for every call you make, it first goes to the foundry server which returns the error of "invalid source" and then the Forge module falls back on browsing the assets library. I hope this helps make it much more efficient! 👍