Usage with express & multer@next (multer v2) with s3
importmulterfrom"multer";// multer v2 (!)import{S3Client}from"@aws-sdk/client-s3";import{expressHandleIncomingStreams,ServiceFileStreamS3,expressSendStreamForGet}from"@artesa/feathers-file-stream";constmulterInstance=multer();consts3=newS3Client({credentials: {accessKeyId: "",secretAccessKey: ""}});app.use("/uploads",multerInstance.array("files"),// looks for files and puts them in req.filesexpressHandleIncomingStreams({field: "files",isArray: true}),// looks for req.files and puts them in req.body, so that it arrives at the service data object in the create methodnewServiceFileStreamS3({s3: newS3Client({credentials: {accessKeyId: "",secretAccessKey: ""}}),bucket: "my-bucket"}),expressSendStreamForGet()// pipes the stream for a get request to the response);
Upload a file with stream
app.service("uploads").create({id: "my-file.txt",// the filename to savestream: fs.createReadStream("my-file.txt")// the stream to read});
The Tidelift Subscription provides access to a continuously curated stream of human-researched and maintainer-verified data on open source packages and their licenses, releases, vulnerabilities, and development practices.