forked from docs/doc-exports
Reviewed-by: Eotvos, Oliver <oliver.eotvos@t-systems.com> Co-authored-by: Chen, Junjie <chenjunjie@huawei.com> Co-committed-by: Chen, Junjie <chenjunjie@huawei.com>
17 lines
2.4 KiB
HTML
17 lines
2.4 KiB
HTML
<a name="functiongraph_03_0330"></a><a name="functiongraph_03_0330"></a>
|
|
|
|
<h1 class="topictitle1">How Does a Function Read or Write Files?</h1>
|
|
<div id="body1564213083976"><div class="section" id="functiongraph_03_0330__section5963328203913"><h4 class="sectiontitle">Background</h4><p id="functiongraph_03_0330__p10873165913174">A function can read files in the code directory. The working directory of a function is the upper-level directory of the handler file. Assume that you have uploaded a folder named <strong id="functiongraph_03_0330__b1362420164920">backend</strong>. To read its <strong id="functiongraph_03_0330__b106862018492">test.conf</strong> file in the same level of directory as the handler file, use relative path <strong id="functiongraph_03_0330__b116815206491">code/backend/test.conf</strong> or use a full path (that is, the value of the <strong id="functiongraph_03_0330__b196919204497">RUNTIME_CODE_ROOT</strong> environment variable). To write a file (for example, to create or download a file), go to the <strong id="functiongraph_03_0330__b176295134015">/tmp</strong> directory or use the file system mounting feature provided by FunctionGraph.</p>
|
|
<div class="note" id="functiongraph_03_0330__note629971912211"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="functiongraph_03_0330__ul1111055816248"><li id="functiongraph_03_0330__li711010582242">If containers are reclaimed, file read/written content will become invalid.</li><li id="functiongraph_03_0330__li197990122513">Currently, FunctionGraph does not support instance persistence.</li></ul>
|
|
</div></div>
|
|
</div>
|
|
<div class="section" id="functiongraph_03_0330__section18318115019398"><h4 class="sectiontitle">Typical Scenarios</h4><ul id="functiongraph_03_0330__ul14488914102711"><li id="functiongraph_03_0330__li5883101712271">Download files stored in Object Storage Service (OBS) to the <strong id="functiongraph_03_0330__b1313154318279">/tmp</strong> directory for processing.</li><li id="functiongraph_03_0330__li1248816142278">To store function execution data in OBS, create a file in the <strong id="functiongraph_03_0330__b134402033121815">/tmp</strong> directory, write the data into the file, and then upload the file to OBS.</li></ul>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="functiongraph_03_0110_00.html">General FAQs</a></div>
|
|
</div>
|
|
</div>
|
|
|