Skip to content

How to write blob into the device #634

Answered by gws0920
gws0920 asked this question in Q&A
Discussion options

You must be logged in to vote

我在这里找到了参考

https://github.com/yume-chan/ya-webadb/blob/b066ca01e7c6d17e02c969db94c458f9cd5d0463/apps/demo/src/pages/file-manager.tsx

const fileHandles = await showOpenFilePicker({ multiple: true })
  const adb = getAdb()
  const sync = await adb?.sync()
  if (!sync) return

  for (let i = 0; i < fileHandles.length; i++) {
    const fileHandle = fileHandles[i]
    const file = await fileHandle.getFile()
    const stream = new WrapReadableStream<Uint8Array>(
      file.stream() as unknown as ReadableStream<Uint8Array>
    )
      .pipeThrough(new WrapConsumableStream())
      .pipeThrough(new ProgressStream((v) => {
        console.log('progress: ', +(v / file.size * 100).toFixed(1) + '%')

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@yume-chan
Comment options

@gws0920
Comment options

Answer selected by gws0920
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants