Can't read all bytes from a file.
Nobody has claimed this yet.
Assessment
- Difficulty
- 1/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 50/100
- Issue type
- Documentation
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- javascript
- Domain
- documentation
Research direction
Open the plugin file-system page at https://v2.tauri.app/plugin/file-system/ and locate the documented JavaScript example using open(), read(), and Uint8Array. Compare it with the reported behavior, then update the sample and surrounding explanation so the documented read succeeds with the required buffer handling.
Written by the indexing model from the issue text.
Description
I followed the sample code on this document https://v2.tauri.app/plugin/file-system/
import { open, BaseDirectory } from '@tauri-apps/plugin-fs';
const file = await open('foo/bar.txt', {
read: true,
baseDir: BaseDirectory.App,
});
const buf = new Uint8Array();
await file.read(buf);
const textContents = new TextDecoder().decode(buf);
await file.close();
but it reads zero bytes,
I found out that I need to preallocate buf, otherwise it won't read anything. this behavior is different from what's documented.
const buf = new Uint8Array(100);
What I have to do is the following:
const stat = await fileHandle.stat();
const contentBuffer = new Uint8Array(stat.size);
await fileHandle.read(contentBuffer);
await fileHandle.close();
- Dominant language
- MDX
- Stars
- 1.1k
- Forks
- 887
- Avg merge
- 2d 8h
- Merged PRs (30d)
- 48
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from tauri-apps/tauri-docs
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
tauri-apps/tauri-docs#2839 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 65/100
tauri-apps/tauri-docs#2739 · 2 reactions ·
-
discuss enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
tauri-apps/tauri-docs#2567 ·
-
tauri-apps/tauri-docs#3999 · 3 comments · 1 assignee ·
-
bug
tauri-apps/tauri-docs#3930 · 1 assignee ·
All issues in tauri-apps/tauri-docs
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
bancolombia/sentinel#22 ·
-
test md OpenCI
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
optimization optimization:agents-md-curator
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
githubnext/gh-aw-cao#13143 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 94/100
objectionary/hone-maven-plugin#1061 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
redhat-developer/rhdh-plugins#4887 · 2 comments ·