Skip to content

Commit 3a4336b

Browse files
fix. readFile function
1 parent ff714a4 commit 3a4336b

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

src/fileSystem/internalFs.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Directory, Encoding, Filesystem } from "@capacitor/filesystem";
22
import ajax from "@deadlyjack/ajax";
3+
import { data } from "autoprefixer";
34
import fsOperation from "fileSystem";
45
import path from "path-browserify";
56
import Url from "utils/Url";
@@ -125,15 +126,11 @@ const internalFs = {
125126
reject = setMessage(reject);
126127
Filesystem.readFile({ path: filename, encoding: Encoding.UTF8 })
127128
.then((readFileResult) => {
128-
const fileReader = new FileReader();
129-
fileReader.onerror = reject;
130-
fileReader.readAsArrayBuffer(readFileResult.data);
131-
fileReader.onloadend = () => {
132-
console.log(
133-
`Successfully Read File contents for "${filename}" file.`,
134-
);
135-
resolve({ data: fileReader.result });
136-
};
129+
130+
const encoder = new TextEncoder();
131+
const buffer = encoder.encode(readFileResult.data).buffer;
132+
133+
resolve({data : buffer})
137134
})
138135
.catch((error) => {
139136
console.error(

src/lib/logger.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class Logger {
100100
await fsOperation(logFilePath).writeFile(newData);
101101
}
102102
} catch (error) {
103-
console.error("Error in handling fs operation on log file. Error:", err);
103+
console.error("Error in handling fs operation on log file. Error:", error);
104104
}
105105
};
106106

0 commit comments

Comments
 (0)