Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get access to S3 upload response #984

Open
dorsett85 opened this issue Jan 1, 2025 · 0 comments
Open

Get access to S3 upload response #984

dorsett85 opened this issue Jan 1, 2025 · 0 comments

Comments

@dorsett85
Copy link

Support plan

  • which support plan is this issue covered by? (e.g. Community, Sponsor, or
    Enterprise): community
  • is this issue currently blocking your project? (yes/no): no
  • is this issue affecting a production system? (yes/no): no

Context

  • node version: 22.11.0
  • module (formidable) version: 3.5.2
  • environment (e.g. node, browser, native, OS): node
  • used with (i.e. popular names of modules): @aws-sdk/client-s3, @aws-sdk/lib-storage
  • any other relevant information:

What problem are you trying to solve?

Using this example from the docs, I'd like to be able to get the return value of the s3.upload call to store some data in a db record. I'm using the newer aws client libs (@aws-sdk/client-s3 and @aws-sdk/lib-storage), but it is basically the same thing as the example link. The following snippet shows where I'm trying to access the data:

const form = formidable({
  keepExtensions: true,
  fileWriteStreamHandler: (file) => {
    const pass = new PassThrough();
    if (!(file instanceof VolatileFile)) {
      return pass;
    }

    // This promise returns data I'd like to use after the parse call below
    new Upload({
      client: s3Client,
      params: {
        Bucket: 'BUCKET_NAME',
        Key: file.newFilename,
        Body: pass,
      },
    }).done();

    return pass;
  },
});

const files = (await form.parse(req))[1];

// Do something with files and return value of `new Upload` above  
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant