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
|
||||||
|
|
||||||
| Format | Description |
|
| Format | Description |
|
||||||
| ---------- | ----------------------------------------------- |
|
| ---------- | -------------------------------------------------------- |
|
||||||
| "identiy" | Use data as is; note that json is UTF-8 encoded |
|
| "identiy" | Use data as is; note that JSON strings are UTF-8 encoded |
|
||||||
|
| "base64" | data is base64 encoded |
|
||||||
|
|
||||||
# Build and run
|
# Build and run
|
||||||
|
|
||||||
|
@ -117,8 +117,8 @@ class FileSystem {
|
|||||||
let end = Math.min(offset + length, entry.contents.length);
|
let end = Math.min(offset + length, entry.contents.length);
|
||||||
let data = (offset < entry.contents.length) ? entry.contents.substring(offset, end) : "";
|
let data = (offset < entry.contents.length) ? entry.contents.substring(offset, end) : "";
|
||||||
result = {
|
result = {
|
||||||
data: data,
|
data: btoa(data),
|
||||||
format: "identity",
|
format: "base64",
|
||||||
count: data.length
|
count: data.length
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <jansson.h>
|
#include <jansson.h>
|
||||||
|
#include <libwebsockets.h>
|
||||||
|
|
||||||
#include "wsfs/jsonrpc/server.h"
|
#include "wsfs/jsonrpc/server.h"
|
||||||
|
|
||||||
@ -25,6 +26,10 @@ static wsfs_status wsfs_fill_buffer(
|
|||||||
{
|
{
|
||||||
memcpy(buffer, data, copy_count);
|
memcpy(buffer, data, copy_count);
|
||||||
}
|
}
|
||||||
|
else if (0 == strcmp("base64", format))
|
||||||
|
{
|
||||||
|
lws_b64_decode_string(data, buffer, copy_count);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
status = WSFS_BAD;
|
status = WSFS_BAD;
|
||||||
|
Loading…
Reference in New Issue
Block a user