Handle inline images and attachments via data urls

This commit is contained in:
Zef Hemel
2023-01-08 15:29:34 +01:00
parent 0365673c41
commit 8dac58f38a
7 changed files with 53 additions and 16 deletions
+16
View File
@@ -35,12 +35,24 @@ export function getAttachmentMeta(name: string): Promise<AttachmentMeta> {
return syscall("space.getAttachmentMeta", name);
}
/**
* Read an attachment from the space
* @param name path of the attachment to read
* @returns the attachment data encoded as a data URL
*/
export function readAttachment(
name: string,
): Promise<string> {
return syscall("space.readAttachment", name);
}
/**
* Writes an attachment to the space
* @param name path of the attachment to write
* @param encoding encoding of the data ("string" or "dataurl)
* @param data data itself
* @returns
*/
export function writeAttachment(
name: string,
encoding: "string" | "dataurl",
@@ -49,6 +61,10 @@ export function writeAttachment(
return syscall("space.writeAttachment", name, encoding, data);
}
/**
* Deletes an attachment from the space
* @param name path of the attachment to delete
*/
export function deleteAttachment(name: string): Promise<void> {
return syscall("space.deleteAttachment", name);
}