Gathering detailed insights and metrics for fetch-blob
Gathering detailed insights and metrics for fetch-blob
Gathering detailed insights and metrics for fetch-blob
Gathering detailed insights and metrics for fetch-blob
@types/rn-fetch-blob
TypeScript definitions for rn-fetch-blob
@types/react-native-fetch-blob
TypeScript definitions for react-native-fetch-blob
@kirishima/fetch
https://github.com/kirishima-ship/fetch/blob/main/README.md
rn-fetch-blob
A module provides upload, download, and files access API. Supports file stream read/write for process large files.
A Blob implementation in Node.js, originally from node-fetch.
npm install fetch-blob
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
61 Stars
98 Commits
29 Forks
6 Watching
6 Branches
16 Contributors
Updated on 08 Jun 2024
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
2.2%
1,062,861
Compared to previous day
Last week
3.5%
5,699,034
Compared to previous week
Last month
10.3%
23,623,822
Compared to previous month
Last year
60.8%
233,563,787
Compared to previous year
1
3
A Blob implementation in Node.js, originally from node-fetch.
Use the built-in Blob
in Node.js 18 and later.
1npm install fetch-blob
Updating from 2 to 3 should be a breeze since there is not many changes to the blob specification.
The major cause of a major release is coding standards.
- internal WeakMaps was replaced with private fields
- internal Buffer.from was replaced with TextEncoder/Decoder
- internal buffers was replaced with Uint8Arrays
- CommonJS was replaced with ESM
- The node stream returned by calling blob.stream()
was replaced with whatwg streams
- (Read "Differences from other blobs" for more info.)
buffer.Blob
(Added in: v15.7.0) and browser native Blob this polyfilled version can't be sent via PostMessageBlobDataItem
created in from.js
that wraps a file path into a blob-like item and read lazily (nodejs plans to implement this as well)blob.stream()
is the most noticeable differences. It returns a WHATWG stream now. to keep it as a node stream you would have to do:1 import {Readable} from 'stream' 2 const stream = Readable.from(blob.stream())
1// Ways to import 2import { Blob } from 'fetch-blob' 3import { File } from 'fetch-blob/file.js' 4 5const { Blob } = await import('fetch-blob') 6 7 8// Ways to read the blob: 9const blob = new Blob(['hello, world']) 10 11await blob.text() 12await blob.arrayBuffer() 13for await (let chunk of blob.stream()) { ... } 14blob.stream().getReader().read() 15blob.stream().getReader({mode: 'byob'}).read(view)
fetch-blob/from.js
comes packed with tools to convert any filepath into either a Blob or a File
It will not read the content into memory. It will only stat the file for last modified date and file size.
1// The default export is sync and use fs.stat to retrieve size & last modified as a blob 2import {File, Blob, blobFrom, blobFromSync, fileFrom, fileFromSync} from 'fetch-blob/from.js' 3 4const fsFile = fileFromSync('./2-GiB-file.bin', 'application/octet-stream') 5const fsBlob = await blobFrom('./2-GiB-file.mp4') 6 7// Not a 4 GiB memory snapshot, just holds references 8// points to where data is located on the disk 9const blob = new Blob([fsFile, fsBlob, 'memory', new Uint8Array(10)]) 10console.log(blob.size) // ~4 GiB
blobFrom|blobFromSync|fileFrom|fileFromSync(path, [mimetype])
(requires FinalizationRegistry - node v14.6)
When using both createTemporaryBlob
and createTemporaryFile
then you will write data to the temporary folder in their respective OS.
The arguments can be anything that fsPromises.writeFile supports. NodeJS
v14.17.0+ also supports writing (async)Iterable streams and passing in a
AbortSignal, so both NodeJS stream and whatwg streams are supported. When the
file have been written it will return a Blob/File handle with a references to
this temporary location on the disk. When you no longer have a references to
this Blob/File anymore and it have been GC then it will automatically be deleted.
This files are also unlinked upon exiting the process.
1import { createTemporaryBlob, createTemporaryFile } from 'fetch-blob/from.js' 2 3const req = new Request('https://httpbin.org/image/png') 4const res = await fetch(req) 5const type = res.headers.get('content-type') 6const signal = req.signal 7let blob = await createTemporaryBlob(res.body, { type, signal }) 8// const file = createTemporaryBlob(res.body, 'img.png', { type, signal }) 9blob = undefined // loosing references will delete the file from disk
createTemporaryBlob(data, { type, signal })
createTemporaryFile(data, FileName, { type, signal, lastModified })
Our Blob & File class are more generic then any other polyfills in the way that it can accept any blob look-a-like item
An example of this is that our blob implementation can be constructed with parts coming from BlobDataItem (aka a filepath) or from buffer.Blob, It dose not have to implement all the methods - just enough that it can be read/understood by our Blob implementation. The minium requirements is that it has Symbol.toStringTag
, size
, slice()
, stream()
methods (the stream method
can be as simple as being a sync or async iterator that yields Uint8Arrays. If you then wrap it in our Blob or File new Blob([blobDataItem])
then you get all of the other methods that should be implemented in a blob or file (aka: text(), arrayBuffer() and type and a ReadableStream)
An example of this could be to create a file or blob like item coming from a remote HTTP request. Or from a DataBase
See the MDN documentation and tests for more details of how to use the Blob.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 8/29 approved changesets -- score normalized to 2
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More