Skip to content

appendFile ​

Appends binary content to the end of a file.

Example ​

ts
import { 
SF
} from "@duplojs/server-utils";
import {
E
} from "@duplojs/utils";
const
payload
= new
TextEncoder
().
encode
("I ❤️ DuploJS \n");
const
result
= await
SF
.
appendFile
("/tmp/file.bin",
payload
);
// result: E.Ok | SF.FileSystemLeft<"append-file"> if (
E
.
isRight
(
result
)) {
// encoded "I ❤️ DuploJS" append with success }

Syntax ​

typescript
function appendFile(
  path: string,
  data: Uint8Array
): Promise<FileSystemLeft<"append-file"> | E.Ok>

Parameters ​

  • path : target file path.
  • data : binary content to append.

Return value ​

  • E.Ok : if the operation succeeds.
  • FileSystemLeft<"append-file"> : if the operation fails.

See also ​

Released under the MIT license.