RocketChat / Rocket.Chat.Apps-engine

The Rocket.Chat Apps engine and definitions.

Home Page:https://rocketchat.github.io/Rocket.Chat.Apps-engine/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow Apps to read their own files

cuonghuunguyen opened this issue · comments

Apps may need to read their own files. It allows the apps to have more assets and abilities. Some possible use cases:

  • Storing text asset files
  • Storing image/video files
  • Storing template file (message template, response template)

So, how would you propose packaging these files up and enabling Apps to access them? What sort of API are you thinking? If you can do pseudo code or even come up with an example, that would be great and helpful!

for the moment I am thinking of the AppStorageBridge. We already had the AppSourceStorage, we just need to expose the possibility to read the app's file via IRead accessor.

Okay, so the compiler currently does not compile images except for the logo in the zip file. This was done intentionally since the Apps Engine does not currently support this feature.

How would you recommend the compiler (CLI and compiler) to know which images/assets to include? Do we add an assets property to the app.json file so the developer tells the compiler which folder to include?

Yes, assets prop is ideal.
I have my own apps cli and it is using the same method to include assets

Hint, mine uses assets as an array of glob strings

Okay, so interesting enough there's already the concept of Assets in the Apps Engine...but I fail to see where Apps can access the assets declared.

Here's it in the app.json schema

"assetsFolder": {
"type": "string",
"description": "The name of the folder which contains all of your resources, it should not start with a period."
}

And here it is in the definition

import { IAsset } from './IAsset';
import { IAssetProvider } from './IAssetProvider';
export { IAsset, IAssetProvider };

From the commit messages, I am realizing that these are left over from the initial concept phase of the entire Apps system (https://github.com/RocketChat/Rocket.Chat.Apps-ts-definition/commits/master/src/assets). They were never actually implemented 😬

oh, cool. I've never seen it. So there's could be a chance to have it implemented