You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Note 1: When using with native Blob or fetch-blob@2 you might also need to generate boundary string for your FormDataEncoder instance
89
+
// because Blob will lowercase value of the `type` option and default boundary generator produces a string with both lower and upper cased alphabetical characters.
90
+
constencoder=newFormDataEncoder(form)
89
91
90
92
constoptions= {
91
93
method:"post",
92
94
93
-
// To use this approach with fetch-blob@2 you probably gonna need to convert the encoder parts output to an array first:
94
-
// new Blob([...encoder], {type: encoder.connectType})
95
+
//Note 2: To use this approach with fetch-blob@2 you probably gonna need to convert the encoder parts output to an array first:
96
+
// new Blob([...encoder], {type: encoder.contentType})
95
97
body:newBlob(encoder, {type:encoder.contentType})
96
98
}
97
99
@@ -110,6 +112,7 @@ import {FormDataEncoder} from "form-data-encoder"
110
112
importBlobfrom"fetch-blob"
111
113
importfetchfrom"node-fetch"
112
114
115
+
// This approach may require much more RAM compared to the previous one, but it works too.
113
116
asyncfunctiontoBlob(form) {
114
117
constencoder=newEncoder(form)
115
118
constchunks= []
@@ -121,14 +124,14 @@ async function toBlob(form) {
// Note that node-fetch@2 performs more strictness tests for Blob objects, so you may need to do extra steps before you set up request body (like, maybe you'll need to instaniate a Blob with BlobDataItem as one of its blobPart)
181
184
constblob=newBlobDataItem(enocoder) // or new Blob([new BlobDataItem(enocoder)], {type: encoder.contentType})
@@ -199,28 +202,32 @@ import {FormData} from "formdata-node"
0 commit comments