GithubHelp home page GithubHelp logo

kyh / multer-s3 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gmenih/multer-s3

9.0 9.0 13.0 108 KB

multer storage engine for amazon s3 with added transform option

License: MIT License

JavaScript 100.00%
amazon aws multer multer-s3

multer-s3's Introduction

multer-s3's People

Contributors

briandonahue avatar franciscotfmc avatar gmenih avatar igneosaur avatar jacobtomlinson avatar kyh avatar liamederzeel avatar linusu avatar lukechilds avatar rdpacheco avatar satyajeetcmm avatar subinsebastien avatar thebergamo avatar wgminer avatar woss avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

multer-s3's Issues

AUTO_CONTENT_TYPE does not support SVGs

Like the description says, using AUTO_CONTENT_TYPE does not work for SVG files. This issue comes from multer-s3, as found here. anacronw#126

If we could get this package updated with the latest changes, this problem would be fixed. Are there any plans to get this package up to date with the original multer-s3?

Typos in resize snippet

There are typos in the resize code snippets. The function sharp().jpg() does not exist, it should be sharp().jpeg()

Support for AWS-SDK v3

Hello @kyh,
Do you plan to update this lib to support AWS-SDK v3? I see there is already a pull request for this (#23) but still not merged. It will be great to have this change up and running since AWS keeps telling us to update.

Thanks for writing this library.

Is possible decompress a file/dir and sending all files to s3?

I need to unzip a directory, inside I have some files of some different extensions. How do I do this using this library?

s3: multerS3({
        s3: new aws.S3(),
        bucket: process.env.BUCKET_NAME,
        shouldTransform: function (req, file, cb) {
            () => {}
        },
        transforms: [
            {
                id: "original",
                key: (request, files, callback) => {
                    console.log("F", files);

                    crypto.randomBytes(16, (error, hash) => {
                        if (error) callback(error);

                        const fileName = `${hash.toString("hex")}-${
                            files.originalname
                        }`;

                        callback(null, fileName);
                    });
                },
                transform: (request, files, callback) => {
                    console.log("F1", files);
                },
            },
        ],
        contentType: multerS3.AUTO_CONTENT_TYPE,
        acl: "public-read",
    }),

Video transforms

How could we approach video transformations using fluent-ffmpeg by using the same technique as transforms of images with sharp? ping: @kyh

TypeError: Cannot read property 'length' of undefined

Hi,
I've been trying to upload image with transform using this package. but I don't want to upload file larger than 1MB in size. So, I've set my multer as following,

const upload = multer({
  storage,
  limits: { fileSize: 1000000 }, //1000000 bytes = 1MB
  fileFilter: function (req, file, cb) {
    checkFileType(file, cb);
  },
});

When I upload file smaller than 1MB, It works fine. If I give a file larger than 1MB, it should give me MulterError with LIMIT_FILE_SIZE code. But it gives me TypeError: Cannot read property 'length' of undefined

this is the error stack

TypeError: Cannot read property 'length' of undefined
    at FileAppender.removePlaceholder (D:\mirasel\Test_project\node_modules\multer\lib\file-appender.js:48:49)
    at D:\mirasel\Test_project\node_modules\multer\lib\make-middleware.js:147:22
    at ManagedUpload.callback (D:\mirasel\Test_project\node_modules\multer-s3-transform\index.js:400:29)
    at ManagedUpload.cleanup (D:\mirasel\Test_project\node_modules\aws-sdk\lib\s3\managed_upload.js:635:10)
    at Sharp.<anonymous> (D:\mirasel\Test_project\node_modules\aws-sdk\lib\s3\managed_upload.js:187:44)
    at Sharp.emit (events.js:400:28)
    at Sharp.emit (domain.js:470:12)
    at Object.<anonymous> (D:\mirasel\Test_project\node_modules\sharp\lib\output.js:1075:18)

Passing variable with transforms option

This is my code block
transforms: [
{
id: 'original',
key: function (req, file, cb) {
SHA256(Date.now().toString() + Math.random().toString()).then(Hash => {
cb(null, new Date().toISOString().slice(0, 10) + '-' + Hash +'.webp');
}).catch(err => {
cb(null, new Date().toISOString().slice(0, 10) + '-' + Math.random().toString() +'.webp');
})
},
transform: function (req, file, cb) {
cb(null, sharp().webp());
},
},
{
id: 'thumbnail',
key: function (req, file, cb) {
SHA256(Date.now().toString() + Math.random().toString()).then(Hash => {
cb(null, new Date().toISOString().slice(0, 10) + '-' + Hash +'.webp');
}).catch(err => {
cb(null, new Date().toISOString().slice(0, 10) + '-' + Math.random().toString() +'.webp');
})
},
transform: function (req, file, cb) {
cb(null, sharp().resize(100, 100).jpg())
}
}
],

Now the issue is what i want is thumbnail image name to be original-thumbnail.
but as there is no way to pass variables, it's not possible for me to do this.

Is there any way to achieve this ?

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.