0

This is the working flow of my application:

  1. Get the data from sources.
  2. Perform some operations.
  3. Save the data on a csv file created locally.
  4. After the completion, upload the csv to S3 and delete the local file.

However, when I tried to deploy this application in heroku, I get an error in writeFileSync and cannot create files. To tackle that, I want to store the csv values in a nested array, and then upload directly to S3 as a csv file without local interference.

How do I achieve this? If there are better approaches, please do mention.

crosie
  • 45
  • 1
  • 4

1 Answers1

1

Yes, you can write strings directly to S3 using the AWS SDK's putObject method.

The Body parameter can be one of:

  • Buffer
  • string value
  • stream
jarmod
  • 71,565
  • 16
  • 115
  • 122
  • Thanks @jarmod. Can you also help me to for setting up writeStreams directly to S3? Any tutorials or stackoverflow answers? – crosie Feb 28 '22 at 03:39
  • 1
    There are a couple of streaming example [here](https://stackoverflow.com/questions/37336050/pipe-a-stream-to-s3-upload). – jarmod Feb 28 '22 at 16:10