Closed jimmywarting closed 3 years ago
Not sure how could I adopt this. Personally I'd prefer to have File class for that, but since we have no such thing in Node (as far as I know), I decided to make bare-minimal implementation, just to have spec compatibility. It would be really nice to have your solution in some 3rd party File class implementation.
Anyway, maybe I need to add examples how to use formdata-node
to upload files. I totally will mention your solution as well. For more clarification. And since my library supports not only Blob, File, ReadStream and Buffer as field's content.
replace your file class with the one i provided. then you can construct your own spec compatibility file instance.
if you like to create a file backed up by the filesystem first create a blob using blobFrom
and then wrap it around the file class like this:
const parts = [ blobFrom('./package.json') ]
new File(parts, 'filename', {...})
Sorry for the late response. Your solution will be included once I finish to port the project over TypeScript and release the 3.x version. Actually, it is included already.
And the File class now inherits fetch-blob: https://github.com/octet-stream/form-data/blob/ef791f018e4da293fdef40181765c84b82670b5e/lib/File.ts#L8
So, this change available in https://github.com/octet-stream/form-data/releases/tag/v3.0.0. I believe this issue is now resolved.
I have just released a feature in fetch-blob to create blobs backed up by the filesystem. (but it dosen't contain a File class)
Here is what i have been doing in my own project
Was thinking maybe you would be in any intresset of this or mention it in the readme somewhere. (now the File class is not necessary but it's maybe something you would like to adapt?)
Here is how without the File class npm install formdata-node fetch-blob domexception