GithubHelp home page GithubHelp logo

Comments (1)

milon27 avatar milon27 commented on July 16, 2024

i have build this type def please create and publish a type def library

if anyone wants to use it for now,

  • in tsconfig.json file
"typeRoots": [
      "./node_module/@types",
      "./src/types" // add this typeroot
    ]
  • now inside the /src/types folder create multer-s3-transform/index.d.ts file and paste the bellow code
declare module 'multer-s3-transform' {

    // import { S3Client } from '@aws-sdk/client-s3';
    import S3 from 'aws-sdk/clients/s3';
    import { StorageEngine } from "multer";
    import { Sharp } from 'sharp'

    interface Itransform {
        id: string; //'original'/ 'thumbnail'
        key?(req: Express.Request, file: Express.Multer.File, callback: (error: any, key?: string) => void): void;
        transform(req: Express.Request, file: Express.Multer.File, callback: (error: any, sharpInstance: Sharp) => void): void;
    }

    interface Options {
        s3: S3;
        bucket: ((req: Express.Request, file: Express.Multer.File, callback: (error: any, bucket?: string) => void) => void) | string;
        key?(req: Express.Request, file: Express.Multer.File, callback: (error: any, key?: string) => void): void;
        acl?: ((req: Express.Request, file: Express.Multer.File, callback: (error: any, acl?: string) => void) => void) | string | undefined;
        contentType?(req: Express.Request, file: Express.Multer.File, callback: (error: any, mime?: string, stream?: NodeJS.ReadableStream) => void): void;
        contentDisposition?: ((req: Express.Request, file: Express.Multer.File, callback: (error: any, contentDisposition?: string) => void) => void) | string | undefined;
        metadata?(req: Express.Request, file: Express.Multer.File, callback: (error: any, metadata?: any) => void): void;
        cacheControl?: ((req: Express.Request, file: Express.Multer.File, callback: (error: any, cacheControl?: string) => void) => void) | string | undefined;
        serverSideEncryption?: ((req: Express.Request, file: Express.Multer.File, callback: (error: any, serverSideEncryption?: string) => void) => void) | string | undefined;
        shouldTransform?(req: Express.Request, file: Express.Multer.File, callback: (error: any, should: boolean) => void): void;
        transforms?: Itransform[];

    }
    interface S3Storage {
        (options?: Options): StorageEngine;

        AUTO_CONTENT_TYPE(
            req: Express.Request,
            file: Express.Multer.File,
            callback: (error: any, mime?: string, stream?: NodeJS.ReadableStream) => void): void;
        DEFAULT_CONTENT_TYPE(
            req: Express.Request,
            file: Express.Multer.File,
            callback: (error: any, mime?: string) => void): void;
    }
    declare const s3Storage: S3Storage;
    export = s3Storage;
}

from multer-s3.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.