Gathering detailed insights and metrics for formstream
Gathering detailed insights and metrics for formstream
multipart/form-data encoded stream, helper for file upload.
npm install formstream
Typescript
Module System
Node Version
NPM Version
JavaScript (95.35%)
TypeScript (4.65%)
Total Downloads
43,449,272
Last Day
27,438
Last Week
143,806
Last Month
733,014
Last Year
10,096,378
145 Stars
57 Commits
19 Forks
17 Watching
1 Branches
25 Contributors
Minified
Minified + Gzipped
Latest Version
1.5.1
Package Id
formstream@1.5.1
Unpacked Size
21.61 kB
Size
6.41 kB
File Count
5
NPM Version
10.7.0
Node Version
18.20.3
Publised On
07 Jun 2024
Cumulative downloads
Total Downloads
Last day
-14.9%
27,438
Compared to previous day
Last week
-21.1%
143,806
Compared to previous week
Last month
-2.1%
733,014
Compared to previous month
Last year
-32.4%
10,096,378
Compared to previous year
4
A multipart/form-data encoded stream, helper for file upload.
1npm install formstream
1var formstream = require('formstream'); 2var http = require('http'); 3 4var form = formstream(); 5 6// form.file('file', filepath, filename); 7form.file('file', './logo.png', 'upload-logo.png'); 8 9// other form fields 10form.field('foo', 'fengmk2').field('love', 'aerdeng'); 11 12// even send file content buffer directly 13// form.buffer(name, buffer, filename, mimeType) 14form.buffer('file2', new Buffer('This is file2 content.'), 'foo.txt'); 15 16var options = { 17 method: 'POST', 18 host: 'upload.cnodejs.net', 19 path: '/store', 20 headers: form.headers() 21}; 22var req = http.request(options, function (res) { 23 console.log('Status: %s', res.statusCode); 24 res.on('data', function (data) { 25 console.log(data.toString()); 26 }); 27}); 28 29form.pipe(req);
1var fs = require('fs'); 2var formstream = require('formstream'); 3 4var filepath = './logo.png'; 5fs.stat(filepath, function (err, stat) { 6 formstream() 7 .field('status', 'share picture') 8 .field('access_token', 'your access token') 9 .file('pic', filepath, 'logo.png', stat.size) 10 .pipe(process.stdout); // your request stream 11});
Some web servers have a limit on the number of chunks, and you can set minChunkSize
to ensure the size of chunk sent to the server.
1var fs = require('fs'); 2var FormStream = require('formstream'); 3 4var filepath = './big-file.zip'; 5fs.stat(filepath, function (err, stat) { 6 new FormStream({ 7 // send >= 2MB chunk buffer size to the server 8 minChunkSize: 1024 * 1024 * 2, 9 }).field('status', 'share file') 10 .field('access_token', 'your access token') 11 .file('file', filepath, 'big-file.zip', stat.size) 12 .pipe(process.stdout); // your request stream 13});
Create a form instance.
Form - form instance
Add a normal field to the form.
Form - form instance
Add a local file to be uploaded to the form.
filepath
if empty)Content-Length
header if not specified)Form - form instance
Add a buffer as a file to upload.
filename
if empty)Form - form instance
Add a readable stream as a file to upload. Event 'error' will be emitted if an error occured.
filename
if empty)Content-Length
header if not specified)Form - form instance
Get headers for the request.
1var headers = form.headers({ 2 'Authorization': 'Bearer kei2akc92jmznvnkeh09sknzdk', 3 'Accept': 'application/vnd.github.v3.full+json' 4});
Object - Headers to be sent.
Emitted if there was an error receiving data.
The 'data' event emits when a Buffer was used.
See Node.js Documentation for more.
Emitted when the stream has received no more 'data' events will happen.
See Node.js Documentation for more.
fengmk2 | xingrz | semantic-release-bot | fjc0k | mrspeiser | dead-horse |
---|---|---|---|---|---|
shaozj |
This project follows the git-contributor spec, auto updated at Wed May 15 2024 00:34:12 GMT+0800
.
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
SAST tool is not run on all commits -- score normalized to 2
Details
Reason
Found 4/30 approved changesets -- score normalized to 1
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
project is not fuzzed
Details
Reason
security policy file not detected
Details
Score
Last Scanned on 2025-01-27
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