# How should i specify params for s3.putObject() ? (node.js)

**URL:** https://forum.serverless.com/t/how-should-i-specify-params-for-s3-putobject-node-js/10128
**Category:** Serverless Framework
**Tags:** aws
**Created:** [December 23, 2019, 2:37am UTC](https://forum.serverless.com/t/how-should-i-specify-params-for-s3-putobject-node-js/10128 "2019-12-23T02:37:12Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![RenatAsadulov](https://avatars.discourse-cdn.com/v4/letter/r/ccd318/32.png) [@RenatAsadulov](https://forum.serverless.com/u/RenatAsadulov)
#### Post date: [December 23, 2019, 2:37am UTC](https://forum.serverless.com/t/how-should-i-specify-params-for-s3-putobject-node-js/10128/1 "2019-12-23T02:37:12Z")

</div>

Hello everybody! I am new to this so sorry for such silly question 😃  
I’m trying to update my .csv file in s3 bucket but got no clue how to handle it.  
Seems like i found the right method but still have nothing in the end.  
Let me show u how i do this.

const params ={

```
    Bucket: 'myBucketName',

    Key: 'something.csv',

    Body: JSON.stringify(itemToUpload)

}

```

s3.putObject(params).promise();

I’m trying to specify my bucket in .yml file but it rejects with an error like “Bucket already exists”.  
What should i do to solve my problem?

---

<div class="post-metadata">

### Author: ![hoang-innomizetech](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/hoang-innomizetech/32/3744_2.png) [@hoang-innomizetech](https://forum.serverless.com/u/hoang-innomizetech)
#### Post date: [December 23, 2019, 2:42am UTC](https://forum.serverless.com/t/how-should-i-specify-params-for-s3-putobject-node-js/10128/2 "2019-12-23T02:42:25Z")

</div>

Post full code should be better

---

<div class="post-metadata">

### Author: ![RenatAsadulov](https://avatars.discourse-cdn.com/v4/letter/r/ccd318/32.png) [@RenatAsadulov](https://forum.serverless.com/u/RenatAsadulov)
#### Post date: [December 23, 2019, 2:46am UTC](https://forum.serverless.com/t/how-should-i-specify-params-for-s3-putobject-node-js/10128/3 "2019-12-23T02:46:27Z")

</div>

const AWS = require(‘aws-sdk’);

const documentClient = new AWS.DynamoDB.DocumentClient();

const s3 = new AWS.S3({ region: ‘eu-west-1’ });

const bucketName = process.env.bucketName;

const fiveMinsInMili = process.env.fiveMinsInMili;

exports.handler = async event =\> {

```
console.log('event', event);

console.log('save to s3 lambda');

const nowTimestamp = new Date().getTime();

const params = {

    TableName: 'Weather',

    Select: "ALL_ATTRIBUTES"

};

const items = await documentClient.scan(params).promise();

const { Items } = items; 

s3.putObject(params).promise();

Items.map(i => {

    if (nowTimestamp - i.timestamp <= fiveMinsInMili) {

        const putParams = {

            Bucket: bucketName,

            Key: 'weather.csv',

            Body: JSON.stringify(i)

        }

        s3.putObject(putParams, (err) => {

            if (err) console.log(err);

            else console.log('Its OK!');

        })

}})

```

};

---

<div class="post-metadata">

### Author: ![RenatAsadulov](https://avatars.discourse-cdn.com/v4/letter/r/ccd318/32.png) [@RenatAsadulov](https://forum.serverless.com/u/RenatAsadulov)
#### Post date: [December 23, 2019, 10:59am UTC](https://forum.serverless.com/t/how-should-i-specify-params-for-s3-putobject-node-js/10128/4 "2019-12-23T10:59:41Z")

</div>

I solved it with adding

- Effect: “Allow”

to .yml file 🙂
