Skip to content
This repository has been archived by the owner on Nov 9, 2023. It is now read-only.

Not able to use it in typescript project #18

Open
milon27 opened this issue Oct 29, 2022 · 1 comment
Open

Not able to use it in typescript project #18

milon27 opened this issue Oct 29, 2022 · 1 comment

Comments

@milon27
Copy link

milon27 commented Oct 29, 2022

image

@milon27
Copy link
Author

milon27 commented Oct 29, 2022

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;
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant