• Start

Language Primitives

/

Data types

Files

SurrealDB allows a bucket to be declared locally or globally to work with files.

Available since: v3.0.0

Files are accessed by a path, which is prefixed with an f to differentiate it from a regular string.

Some examples of file pointers:

/**[test]

[[test.results]]
value = "f"bucket:/some/key/to/a/file.txt""

*/

f"bucket:/some/key/to/a/file.txt";
f"bucket:/some/key/with\ escaped";

To work with the files that can be accessed through these pointers, use the following:

/**[test]

[[test.results]]
value = "NONE"

[[test.results]]
value = "NONE"

[[test.results]]
value = "b"536F6D65207465787420696E73696465""

[[test.results]]
value = "'Some text inside'"

*/

DEFINE BUCKET my_bucket BACKEND "memory";
f"my_bucket:/some_file.txt".put("Some text inside");
f"my_bucket:/some_file.txt".get();
<string>f"my_bucket:/some_file.txt".get();
Output
-------- Query --------

b"536F6D65207465787420696E73696465"

-------- Query --------

'Some text inside'

Was this page helpful?