Skip to content

Commit 31ab384

Browse files
committed
fix docs
1 parent 302e02b commit 31ab384

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

examples/official-site/sqlpage/migrations/24_read_file_as_data_url.sql

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,29 @@ VALUES (
1212
'Returns a [data URL](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs)
1313
containing the contents of the given file.
1414
15+
The file path is relative to the `web root` directory, which is the directory from which your website is served
16+
(not necessarily the directory SQLPage is launched from).
17+
18+
If the given argument is null, the function will return null.
19+
20+
As with other functions, if an error occurs during execution
21+
(because the file does not exist, for instance),
22+
the function will display an error message and the
23+
database query will not be executed.
24+
25+
If you are using a `sqlpage_files` table to store files directly in the database (serverless mode),
26+
the function will attempt to read the file from the database filesystem if it is not found on the local disk,
27+
using the same logic as for serving files in response to HTTP requests.
28+
29+
## MIME type
30+
31+
Data URLs contain the [MIME type](https://en.wikipedia.org/wiki/Media_type) of the file they represent.
32+
If the first argument to this function is call to the `sqlpage.uploaded_file_path` function,
33+
the declared MIME type of the uploaded file transmitted by the browser will be used.
34+
35+
Otherwise, the MIME type will be guessed from the file extension, without looking at the file contents.
36+
37+
1538
## Example: inlining a picture
1639
1740
```sql

examples/official-site/sqlpage/migrations/25_read_file_as_text.sql

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ As with other functions, if an error occurs during execution
2323
the function will display an error message and the
2424
database query will not be executed.
2525
26-
If `database_filesystem_table` is set to a table name in SQLPage''s configuration,
27-
the function will attempt to read the file from the database filesystem if it is not found on the local disk.
26+
If you are using a `sqlpage_files` table to store files directly in the database (serverless mode),
27+
the function will attempt to read the file from the database filesystem if it is not found on the local disk,
28+
using the same logic as for serving files in response to HTTP requests.
2829
2930
## Example
3031

0 commit comments

Comments
 (0)