zaida04 / multer-cloudflare-storage

πŸš€ Multer engine for Cloudflare Images with ease.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

multer-cloudflare-storage

GitHub npm CI workflows

πŸ“₯ Installation

You can install this package from NPM

  • npm install multer-cloudflare-storage
  • yarn add multer-cloudflare-storage

⚑ Usage

import express, { Request, Response } from "express";
import multer from "multer";
import { CloudflareStorage } from "multer-cloudflare-storage";

const app = express();
const uploader = multer({
    storage: new CloudflareStorage("YOUR_CLOUDFLARE_ACCOUNT_ID_HERE", "YOUR_CLOUDFLARE_ACCOUNT_TOKEN_HERE")
});

app.post("/", uploader.single("image"), (req: Request, _res: Response) => {
    console.log(req.file);
    // {
    //     fieldname: 'image',
    //     originalname: 'PLACEHOLDER_IMAGE_NAME.jiff',
    //     encoding: '7bit',
    //     mimetype: 'application/octet-stream',
    //     path: 'https://imagedelivery.net/PLACEHOLDER_ACCOUNT_ID/PLACEHOLDER_IMAGE_ID/public',
    //     filename: null,
    //     destination: 'PLACEHOLDER_IMAGE_ID'
    // }
});

You can find a working example of an Express server with multer and this package here

βœ‹ Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

Please ensure any and all commits pass our tests, linting, and build steps as described in the root package.json.

βš–οΈ LICENSE

Licensed under the MIT License

About

πŸš€ Multer engine for Cloudflare Images with ease.

License:MIT License


Languages

Language:TypeScript 98.1%Language:Shell 1.9%