```js const body = 'lol'; const digest = createHash('md5').update(body).digest("hex"); const cmd =

const body = 'lol';
const digest = createHash('md5').update(body).digest("hex");

const cmd = new PutObjectCommand({Bucket: 'sdk-example', Key: 'dog.png', Body: body});

cmd.middlewareStack.add((next, context) => async (args) => {
    args.request.headers["if-none-match"] = `"${digest}"`;
    const result = await next(args);
    return result;
}, {
    step: "build",
    name: "addETag"
})

const data = await S3.send(cmd);
console.log(data);
Was this page helpful?