formstream 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -4
- package/lib/formstream.js +11 -3
- package/package.json +4 -2
- package/types/formstream.d.ts +3 -1
package/README.md
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
# formstream
|
|
2
2
|
|
|
3
3
|
[![NPM version][npm-image]][npm-url]
|
|
4
|
-
[![Test coverage][coveralls-image]][coveralls-url]
|
|
5
4
|
[![npm download][download-image]][download-url]
|
|
6
5
|
|
|
7
6
|
[npm-image]: https://img.shields.io/npm/v/formstream.svg?style=flat-square
|
|
8
7
|
[npm-url]: https://npmjs.org/package/formstream
|
|
9
|
-
[coveralls-image]: https://img.shields.io/coveralls/node-modules/formstream.svg?style=flat-square
|
|
10
|
-
[coveralls-url]: https://coveralls.io/r/node-modules/formstream?branch=master
|
|
11
8
|
[download-image]: https://img.shields.io/npm/dm/formstream.svg?style=flat-square
|
|
12
9
|
[download-url]: https://npmjs.org/package/formstream
|
|
13
10
|
|
|
@@ -178,7 +175,7 @@ See [Node.js Documentation](http://nodejs.org/api/stream.html#stream_event_end)
|
|
|
178
175
|
|
|
179
176
|
(The MIT License)
|
|
180
177
|
|
|
181
|
-
Copyright (c) 2012 - 2014 fengmk2
|
|
178
|
+
Copyright (c) 2012 - 2014 fengmk2 <fengmk2@gmail.com>
|
|
182
179
|
Copyright(c) node-modules and other contributors.
|
|
183
180
|
|
|
184
181
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
@@ -199,3 +196,14 @@ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
|
199
196
|
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
200
197
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
201
198
|
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
199
|
+
<!-- GITCONTRIBUTOR_START -->
|
|
200
|
+
|
|
201
|
+
## Contributors
|
|
202
|
+
|
|
203
|
+
|[<img src="https://avatars.githubusercontent.com/u/156269?v=4" width="100px;"/><br/><sub><b>fengmk2</b></sub>](https://github.com/fengmk2)<br/>|[<img src="https://avatars.githubusercontent.com/u/288288?v=4" width="100px;"/><br/><sub><b>xingrz</b></sub>](https://github.com/xingrz)<br/>|[<img src="https://avatars.githubusercontent.com/u/32174276?v=4" width="100px;"/><br/><sub><b>semantic-release-bot</b></sub>](https://github.com/semantic-release-bot)<br/>|[<img src="https://avatars.githubusercontent.com/u/13151189?v=4" width="100px;"/><br/><sub><b>fjc0k</b></sub>](https://github.com/fjc0k)<br/>|[<img src="https://avatars.githubusercontent.com/u/18096247?v=4" width="100px;"/><br/><sub><b>mrspeiser</b></sub>](https://github.com/mrspeiser)<br/>|[<img src="https://avatars.githubusercontent.com/u/985607?v=4" width="100px;"/><br/><sub><b>dead-horse</b></sub>](https://github.com/dead-horse)<br/>|
|
|
204
|
+
| :---: | :---: | :---: | :---: | :---: | :---: |
|
|
205
|
+
[<img src="https://avatars.githubusercontent.com/u/7326406?v=4" width="100px;"/><br/><sub><b>shaozj</b></sub>](https://github.com/shaozj)<br/>
|
|
206
|
+
|
|
207
|
+
This project follows the git-contributor [spec](https://github.com/xudafeng/git-contributor), auto updated at `Wed May 15 2024 00:34:12 GMT+0800`.
|
|
208
|
+
|
|
209
|
+
<!-- GITCONTRIBUTOR_END -->
|
package/lib/formstream.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Data format:
|
|
2
|
+
* Form Data format:
|
|
3
3
|
*
|
|
4
4
|
|
|
5
5
|
--FormStreamBoundary1349886663601\r\n
|
|
@@ -7,6 +7,11 @@ Content-Disposition: form-data; name="foo"\r\n
|
|
|
7
7
|
\r\n
|
|
8
8
|
<FIELD-CONTENT>\r\n
|
|
9
9
|
--FormStreamBoundary1349886663601\r\n
|
|
10
|
+
Content-Disposition: form-data; name="data"\r\n
|
|
11
|
+
Content-Type: application/json\r\n
|
|
12
|
+
\r\n
|
|
13
|
+
<JSON-FORMAT-CONTENT>\r\n
|
|
14
|
+
--FormStreamBoundary1349886663601\r\n
|
|
10
15
|
Content-Disposition: form-data; name="file"; filename="formstream.test.js"\r\n
|
|
11
16
|
Content-Type: application/javascript\r\n
|
|
12
17
|
\r\n
|
|
@@ -49,6 +54,8 @@ function FormStream() {
|
|
|
49
54
|
this._contentLength = 0;
|
|
50
55
|
this._isAllStreamSizeKnown = true;
|
|
51
56
|
this._knownStreamSize = 0;
|
|
57
|
+
|
|
58
|
+
this.isFormStream = true;
|
|
52
59
|
}
|
|
53
60
|
|
|
54
61
|
util.inherits(FormStream, Stream);
|
|
@@ -128,9 +135,10 @@ FormStream.prototype.file = function (name, filepath, filename, filesize) {
|
|
|
128
135
|
* Add a form field
|
|
129
136
|
* @param {String} name field name
|
|
130
137
|
* @param {String|Buffer} value field value
|
|
138
|
+
* @param {String} [mimeType] field mimeType
|
|
131
139
|
* @return {this}
|
|
132
140
|
*/
|
|
133
|
-
FormStream.prototype.field = function (name, value) {
|
|
141
|
+
FormStream.prototype.field = function (name, value, mimeType) {
|
|
134
142
|
if (!Buffer.isBuffer(value)) {
|
|
135
143
|
// field(String, Number)
|
|
136
144
|
// https://github.com/qiniu/nodejs-sdk/issues/123
|
|
@@ -139,7 +147,7 @@ FormStream.prototype.field = function (name, value) {
|
|
|
139
147
|
}
|
|
140
148
|
value = Buffer.from(value);
|
|
141
149
|
}
|
|
142
|
-
return this.buffer(name, value);
|
|
150
|
+
return this.buffer(name, value, null, mimeType);
|
|
143
151
|
};
|
|
144
152
|
|
|
145
153
|
FormStream.prototype.stream = function (name, stream, filename, mimeType, size) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "formstream",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "A multipart/form-data encoded stream, helper for file upload.",
|
|
5
5
|
"main": "lib/formstream.js",
|
|
6
6
|
"types": "types/formstream.d.ts",
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
"cov": "egg-bin cov",
|
|
14
14
|
"ci": "npm run lint && npm run tsd && npm run cov",
|
|
15
15
|
"lint": "jshint .",
|
|
16
|
-
"tsd": "tsd"
|
|
16
|
+
"tsd": "tsd",
|
|
17
|
+
"contributor": "git-contributor"
|
|
17
18
|
},
|
|
18
19
|
"repository": {
|
|
19
20
|
"type": "git",
|
|
@@ -38,6 +39,7 @@
|
|
|
38
39
|
"connect-multiparty": "1",
|
|
39
40
|
"egg-bin": "^5.6.1",
|
|
40
41
|
"express": "^4.16.4",
|
|
42
|
+
"git-contributor": "^2.1.5",
|
|
41
43
|
"jshint": "^2.13.6",
|
|
42
44
|
"pedding": "1",
|
|
43
45
|
"should": "4",
|
package/types/formstream.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ declare class FormStream extends Stream {
|
|
|
7
7
|
* @param name Name of field
|
|
8
8
|
* @param value Value of field
|
|
9
9
|
*/
|
|
10
|
-
field(name: string, value: string): this
|
|
10
|
+
field(name: string, value: string, contentType?: string): this
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Add a local file to be uploaded to the form.
|
|
@@ -69,4 +69,6 @@ declare const formStream: {
|
|
|
69
69
|
(): FormStream
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
+
interface formStream extends FormStream {}
|
|
73
|
+
|
|
72
74
|
export = formStream
|