<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Volkan Şentürk</title>
    <description>The latest articles on DEV Community by Volkan Şentürk (@volkansenturk2012).</description>
    <link>https://dev.to/volkansenturk2012</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F307397%2F7adaebb3-29ef-4ec0-8cf0-dc7ba1344bf1.png</url>
      <title>DEV Community: Volkan Şentürk</title>
      <link>https://dev.to/volkansenturk2012</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/volkansenturk2012"/>
    <language>en</language>
    <item>
      <title>How to download s3 object and save to file</title>
      <dc:creator>Volkan Şentürk</dc:creator>
      <pubDate>Fri, 30 Sep 2022 21:06:59 +0000</pubDate>
      <link>https://dev.to/volkansenturk2012/how-to-download-s3-object-and-save-to-file-pgj</link>
      <guid>https://dev.to/volkansenturk2012/how-to-download-s3-object-and-save-to-file-pgj</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import * as fs from "fs";
import * as AWS from "aws-sdk";

const BUCKET_NAME = "&amp;lt;&amp;lt;bucket-name&amp;gt;&amp;gt;";
const IAM_USER_KEY = "&amp;lt;&amp;lt;user-key&amp;gt;&amp;gt;";
const IAM_USER_SECRET = "&amp;lt;&amp;lt;user-secret&amp;gt;&amp;gt;";

const s3bucket = new AWS.S3({
  accessKeyId: IAM_USER_KEY,
  secretAccessKey: IAM_USER_SECRET
});

export function downloadToS3(fileName: string): Promise&amp;lt;any&amp;gt; {

  const params = {
    Bucket: BUCKET_NAME,
    Key: "myapp" + "/" + filename,
  };


  s3bucket.getObject(params, function (err, data) {
    if (err) {
        console.log("error!");
    }
    else {
        fs.createWriteStream(filename).write(data.Body);
        console.log(data.Body);
    }
  });  

  return new Promise((resolve, reject) =&amp;gt; {

  });
}


downloadToS3("&amp;lt;&amp;lt;filename&amp;gt;&amp;gt;")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>aws</category>
      <category>typescript</category>
      <category>javascript</category>
      <category>node</category>
    </item>
  </channel>
</rss>
