0.6.0 • Published 19 days ago

@artesa/feathers-file-stream v0.6.0

Weekly downloads
-
License
MIT
Repository
github
Last release
19 days ago

feathers-file-stream

npm i @artesa/feathers-file-stream

Usage with express & multer@next (multer v2) with fs storage

import multer from "multer"; // multer v2 (!)
import {
  expressHandleIncomingStreams,
  ServiceFileStreamFS,
  expressSendStreamForGet
} from "@artesa/feathers-file-stream";
const multerInstance = multer();

app.use(
  "/uploads",
  multerInstance.array("files"),
  expressHandleIncomingStreams({ field: "files", isArray: true }),
  new ServiceFileStreamFS({
    root: path.join(__dirname, "uploads")
  }),
  expressSendStreamForGet()
);

Usage with express & multer@next (multer v2) with s3

import multer from "multer"; // multer v2 (!)
import { S3Client } from "@aws-sdk/client-s3";
import {
  expressHandleIncomingStreams,
  ServiceFileStreamS3,
  expressSendStreamForGet
} from "@artesa/feathers-file-stream";
const multerInstance = multer();
const s3 = new S3Client({
  credentials: {
    accessKeyId: "",
    secretAccessKey: ""
  }
});

app.use(
  "/uploads",
  multerInstance.array("files"), // looks for files and puts them in req.files
  expressHandleIncomingStreams({ 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 method
  new ServiceFileStreamS3({
    s3: new S3Client({
      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 save
  stream: fs.createReadStream("my-file.txt") // the stream to read
});
0.6.0

19 days ago

0.5.0

1 year ago

0.5.1

1 year ago

0.4.10

1 year ago

0.4.9

1 year ago

0.4.8

1 year ago

0.4.7

1 year ago

0.4.6

1 year ago

0.4.5

1 year ago

0.4.4

1 year ago

0.4.3

1 year ago

0.4.2

1 year ago

0.4.1

1 year ago

0.5.0-0

1 year ago

0.4.0

1 year ago

0.3.2

1 year ago

0.3.1

1 year ago

0.3.0

1 year ago

0.2.0

1 year ago

0.1.11

1 year ago

0.1.10

1 year ago

0.1.9

1 year ago

0.1.8

1 year ago

0.1.7

1 year ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago