Skip to content

how to read file in wasm #117

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

Open
Snailll opened this issue Jun 3, 2021 · 4 comments
Open

how to read file in wasm #117

Snailll opened this issue Jun 3, 2021 · 4 comments

Comments

@Snailll
Copy link

Snailll commented Jun 3, 2021

In the wasm filter ,I want to read some configurations from file.
I wrote some code in the onConfigure part like this

    std::string data;
    std::ifstream infile;
    infile.open("/configurations.json");
    infile >> data;;
    infile.close();
    LOG_ERROR("configurations -> " + data);

Howerev, I cannot get any content of the configuration file.

How to read a configuration file in wasm ? Is there a file read API in the proxy-wasm-cpp-sdk?

Ths.

@bianpengyuan
Copy link
Contributor

Host does not yet support file read ABI: proxy-wasm/proxy-wasm-cpp-host#127

@PiotrSikora
Copy link
Member

The read-only file access is being actively worked on... But why exactly do you need it?

Note that the recommended way to configure plugins is to add the configuration in the proxy config itself, which is then available in the plugin via proxy_get_buffer_bytes(WasmBufferType::PluginConfiguration, ...).

@CalbeeMing0530
Copy link

The read-only file access is being actively worked on... But why exactly do you need it?

Note that the recommended way to configure plugins is to add the configuration in the proxy config itself, which is then available in the plugin via proxy_get_buffer_bytes(WasmBufferType::PluginConfiguration, ...).

This kind of requirement is more common, for example, we use wasm to do some traffic processing work, which will involve policy reading, so we need to read the mounted configuration from the envoy proxy

@CalbeeMing0530
Copy link

@PiotrSikora In addition,If the policy is complex and confidential, it is obviously not wise to put it all in the proxy configuration

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

No branches or pull requests

4 participants