This script is how I always uploaded files to server, but I would like to remove dependecy on node-fetch
library and it has confilicting types of streams.
import {createReadStream} from 'fs';
declare const url: string;
declare cosnt file: {
size: number;
filePath: string;
};
await fetch(url, {
method: 'post',
headers: {
"Content-length": `${file.size}`,
},
body: createReadStream(file.filepath), // These streams are not compatible
});
How to transform native Node stream to native Web stream used by native fetch in Node v18 (and above)?