mirror of
https://github.com/falk-werner/webfuse-provider
synced 2024-10-27 20:44:10 +00:00
add base64 as format for read results
This commit is contained in:
parent
53ed822457
commit
2b7d938315
@ -258,9 +258,10 @@ Read from an open file.
|
||||
|
||||
#### Format
|
||||
|
||||
| Format | Description |
|
||||
| ---------- | ----------------------------------------------- |
|
||||
| "identiy" | Use data as is; note that json is UTF-8 encoded |
|
||||
| Format | Description |
|
||||
| ---------- | -------------------------------------------------------- |
|
||||
| "identiy" | Use data as is; note that JSON strings are UTF-8 encoded |
|
||||
| "base64" | data is base64 encoded |
|
||||
|
||||
# Build and run
|
||||
|
||||
|
@ -117,8 +117,8 @@ class FileSystem {
|
||||
let end = Math.min(offset + length, entry.contents.length);
|
||||
let data = (offset < entry.contents.length) ? entry.contents.substring(offset, end) : "";
|
||||
result = {
|
||||
data: data,
|
||||
format: "identity",
|
||||
data: btoa(data),
|
||||
format: "base64",
|
||||
count: data.length
|
||||
};
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
#include <jansson.h>
|
||||
#include <libwebsockets.h>
|
||||
|
||||
#include "wsfs/jsonrpc/server.h"
|
||||
|
||||
@ -25,6 +26,10 @@ static wsfs_status wsfs_fill_buffer(
|
||||
{
|
||||
memcpy(buffer, data, copy_count);
|
||||
}
|
||||
else if (0 == strcmp("base64", format))
|
||||
{
|
||||
lws_b64_decode_string(data, buffer, copy_count);
|
||||
}
|
||||
else
|
||||
{
|
||||
status = WSFS_BAD;
|
||||
|
Loading…
Reference in New Issue
Block a user