question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

fileWriteStreamHandle doesn't call the passed function in express

See original GitHub issue

Avantages

const { PassThrough } = require("stream");
const aws = require("aws-sdk");

const s3 = new aws.S3({
  apiVersion: "2006-03-01",
  accessKeyId: process.env.AWS_ACCESS_KEY_ID,
  secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
});


function uploadFile(req, res, next) {

  const uploadStream = (filename) => {
    const pass = PassThrough();
    
    /* This method is not being called*/
    console.log('uploadStream() called);

    s3.upload(
        {
        Bucket: process.env.AWS_BUCKET,
        Key: filename,
        Body: pass,
        },
        (err, data) => {
        console.log(err, data);
        if (err) {
            console.log(err);
        }
        console.log(data);
        }
    );
    
    return pass;
  };

  var form = formidable({
    maxFileSize: 5 * 1024 * 1024,
    minFileSize: 1,
    allowEmptyFiles:false,
    fileWriteStreamHandler: uploadStream // This method is not being called
  });
}

I have followed the example in link https://github.com/node-formidable/formidable/blob/master/examples/store-files-on-s3.js

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:20 (11 by maintainers)

github_iconTop GitHub Comments

15reactions
GrosSacASaccommented, Jan 26, 2021

How ?

2reactions
tunnckoCorecommented, Jan 19, 2021

@sinoon there is a published canary/v2 (npm i formidable@canary) from May 2020 with all the updates. Pushed to master since then isn’t published. I’m getting my machine setup this week.

Read more comments on GitHub >

github_iconTop Results From Across the Web

fileWriteStreamHandle doesn't call the passed function in ...
A node.js module for parsing form data, especially file uploads. See More. Top Supporters. This team needs your support!
Read more >
Node.js Express - app.all("*", func) doesn't get called when ...
to call the function doSomething on every page load, but it doesn't completely work. The function fires on every page load, except for...
Read more >
5.x API - Express.js
If not a function, type option is passed directly to the type-is library and this can be an extension name (like json ),...
Read more >
Using Express.js Routes for Promise-based Error Handling
js ) and pass async errors to it using the next callback. Our basic error middleware setup would use a simple anonymous function:...
Read more >
How to Build Middleware for Node.js: A Complete Guide - Turing
When the active middleware function doesn't stop the request-response cycle, it will call the next() function to pass on the control to the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found