Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/meqn/file-access
Easily fetch local or remote file, and return buffer data.
https://github.com/meqn/file-access
fetch-files file-access read-file read-file-into-buffer read-file-sync
Last synced: 2 months ago
JSON representation
Easily fetch local or remote file, and return buffer data.
- Host: GitHub
- URL: https://github.com/meqn/file-access
- Owner: Meqn
- License: mit
- Created: 2023-12-16T14:00:15.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-26T03:50:18.000Z (12 months ago)
- Last Synced: 2023-12-27T03:29:31.451Z (12 months ago)
- Topics: fetch-files, file-access, read-file, read-file-into-buffer, read-file-sync
- Language: TypeScript
- Homepage:
- Size: 99.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# file-access
[![version](https://img.shields.io/npm/v/file-access?style=flat-square)](https://www.npmjs.com/package/file-access)
[![Codecov](https://img.shields.io/codecov/c/github/meqn/file-access?token=1498G3HFKJ&style=flat-square&logo=codecov)](https://codecov.io/gh/Meqn/file-access)
[![release](https://img.shields.io/github/actions/workflow/status/meqn/file-access/release.yml?style=flat-square)](https://github.com/Meqn/pipflow/releases)
[![node.js](https://img.shields.io/node/v/file-access?style=flat-square&logo=nodedotjs)](https://nodejs.org/en/about/releases/)
[![languages](https://img.shields.io/github/languages/top/meqn/file-access?style=flat-square)](https://github.com/Meqn/file-access)Easily fetch local or remote file, and return buffer data.
> Not suitable for accessing large files
轻松获取本地或远程文件, 并返回buffer数据。(不适用于大文件)
## Usage
```js
const {
accessFile,
accessLocalFileSync
} = require('file-access');accessFile('/path/to/local.txt', (err, data) => {
// ...
})accessFile('https://example.com/file.zip').then((data) => {
// ...
console.log('file size : ', data.byteLength)
conosle.log('content-type :', data.contentType)
})const buffer = accessLocalFileSync('/path/to/local.txt')
```