Skip to content

Unable to load database #58

Description

@Nithin3008

`const KdbxReader = () => {
const [db, setDb] = useState(null);
const [error, setError] = useState("");
console.log(kdbxweb); // Should show the library object
console.log(kdbxweb.ProtectedValue);
function readFileAsUint8Array(file) {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onload = () => resolve(new Uint8Array(reader.result));
reader.onerror = reject;
reader.readAsArrayBuffer(file);
});
}

// Usage:

const handleFileChange = async (event) => {
// When user selects a .kdbx file
const file = event.target.files[0];
const buffer = await readFileAsUint8Array(file);
const creds = new kdbxweb.Credentials(
kdbxweb.ProtectedValue.fromString("My password")
);
const db = await kdbxweb.Kdbx.load(buffer, creds);
};
`

I am facing this error continously
"uncaught (in promise) KdbxError: Error InvalidArg: data
at handleFileChange (App.tsx?t=1743508462124:41:36)"

I even tried const buffer = new Uint8Array(await file.arrayBuffer()); but not working
help

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions