Skip to content

LinusU/file-to-array-buffer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

File to ArrayBuffer

Turn a File (or any Blob) into an ArrayBuffer.

Installation

npm install --save file-to-array-buffer

Usage

const fileToArrayBuffer = require('file-to-array-buffer')

// <input id="fileItem" type="file" />
const file = document.getElementById('fileItem').files[0]

fileToArrayBuffer(file).then((data) => {
  console.log(data)
  //=> ArrayBuffer {byteLength: ...}
})

API

fileToArrayBuffer(file: Blob) => Promise<ArrayBuffer>

Read the data of the file into an ArrayBuffer.

About

Turn a File (or any Blob) into an ArrayBuffer

Resources

Stars

Watchers

Forks

Packages

No packages published