<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by UploadBtn on Medium]]></title>
        <description><![CDATA[Stories by UploadBtn on Medium]]></description>
        <link>https://medium.com/@cpatarun?source=rss-69e634ae51c6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*eDPsOPv8ilRQwQBDZ7Uh5w.png</url>
            <title>Stories by UploadBtn on Medium</title>
            <link>https://medium.com/@cpatarun?source=rss-69e634ae51c6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 03:45:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@cpatarun/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Client-side vs server-side file upload to Amazon S3]]></title>
            <link>https://medium.com/@cpatarun/client-side-vs-server-side-file-upload-to-amazon-s3-5c46ac0f4c7f?source=rss-69e634ae51c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/5c46ac0f4c7f</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[file-upload]]></category>
            <dc:creator><![CDATA[UploadBtn]]></dc:creator>
            <pubDate>Wed, 20 Mar 2019 03:10:37 GMT</pubDate>
            <atom:updated>2019-03-20T03:10:37.091Z</atom:updated>
            <content:encoded><![CDATA[<p>You may be wondering what option is better for uploading files to Amazon S3. When you upload files client side, you are sending the file directly from the web browser to your S3 bucket. With server-side uploads, you will first need to send the file to your server and then upload it to S3 from there.</p><p>There is no best option here, each have their own advantages and disadvantages. You will have to weigh up the pros and cons of each option and see what works best for you.</p><h3>Client-side upload to S3</h3><h3>Pros</h3><ul><li>Less load placed on your servers since the file is sent directly to the S3 bucket</li><li>Performance limited only by your users internet connection</li><li>Likely increased reliability as the browser talks directly to S3</li></ul><h3>Cons</h3><ul><li>Requires correctly configured S3 bucket CORS policy</li><li>Need to acquire a S3 signed request URL form your server to upload the file from the browser</li><li>Reduced security as an attacker can bypass any file checks for the upload</li><li>Security concern of attackers overwriting files by uploading files with the same name and path of existing ones</li></ul><h3>Server-side upload to S3</h3><h3>Pros</h3><ul><li>Increased security as the file can be properly assessed in a secure environment (your server)</li><li>Ensure files are uploaded with a unique file path so nothing gets overwritten</li><li>No need to acquire signed request URL to upload files</li><li>Can be simpler to configure depending on your server</li></ul><h3>Cons</h3><ul><li>Increases load on your servers by accepting files and then transmitting it to S3</li><li>Upload performance is determined by how capable your server is</li><li>Greater reliability concerns as your servers must be available to process uploads</li></ul><p>Brought to you by <a href="https://www.uploadbtn.com/">Uploadbtn</a>. The easiest way to upload files to Amazon S3 without a server. Get started uploading files in just 5 minutes</p><p><em>Originally published at </em><a href="https://www.uploadbtn.com/article/client-side-vs-server-side-file-upload-to-amazon-s3"><em>www.uploadbtn.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5c46ac0f4c7f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tracking file upload progress to Amazon S3 from the browser]]></title>
            <link>https://medium.com/@cpatarun/tracking-file-upload-progress-to-amazon-s3-from-the-browser-71be6712c63d?source=rss-69e634ae51c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/71be6712c63d</guid>
            <category><![CDATA[amazon-s3]]></category>
            <category><![CDATA[file-upload]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[UploadBtn]]></dc:creator>
            <pubDate>Wed, 20 Mar 2019 03:08:13 GMT</pubDate>
            <atom:updated>2019-03-20T03:08:13.478Z</atom:updated>
            <content:encoded><![CDATA[<p>Ever wondered how to track the exact upload progress of a file when uploading client-side to Amazon S3? It’s actually a relatively simple task to achieve. This works well with any type of file upload. If you haven’t already setup file uploads to S3, check out this article — <a href="https://www.uploadbtn.com/article/upload-files-browser-to-amazon-s3-with-nodejs">Upload files from browser to Amazon S3 with Node.js</a></p><p>When making the PUT request to Amazon S3 to upload our file, we will make use of the XMLHttpRequest class.</p><pre>var s3SignedUploadUrl = &quot;...&quot;;<br>var file = document.getElementById(&quot;file-input&quot;).files[0];<br>var xhr = new XMLHttpRequest();<br><br>xhr.onreadystatechange = function() {<br>  if (xhr.readyState === 4) {<br>    if (xhr.status === 200) {<br>      console.log(&quot;UPLOAD SUCCESSFUL&quot;);<br>    }<br>    else {<br>      console.log(&quot;UPLOAD FAILED&quot;);<br>    }<br>  }<br>};<br><br>xhr.upload.onprogress = function(e) {<br>    if (e.lengthComputable) {<br>      var percentComplete = (e.loaded / file.size) * 100;<br>    }<br>};<br><br>xhr.open(&quot;PUT&quot;, s3SignedUploadUrl);<br>xhr.send(file);</pre><h3>Using Promises</h3><p>Doing this the normal way is quite painful in application code. As such its best to wrap all this in a promise as follows.</p><pre>function uploadS3(url, file, progressCallback) {<br>  return new Promise(function (resolve, reject) {<br><br>    const xhr = new XMLHttpRequest();<br><br>    xhr.onreadystatechange = () =&gt; {<br>      if (xhr.readyState === 4) {<br>        if (xhr.status === 200) {<br>          resolve(xhr)<br>        }<br>        else {<br>          reject(xhr)<br>        }<br>      }<br>    };<br><br>    if (progressCallback) {<br>      xhr.upload.onprogress = (e) =&gt; {<br>        if (e.lengthComputable) {<br>          var percentComplete = (e.loaded / file.size) * 100;<br>          progressCallback(percentComplete);<br>        }<br>      };<br>    }<br><br>    xhr.open(&quot;PUT&quot;, url);<br>    xhr.send(file);<br>  });<br>}</pre><p>Now this way you can use it much easier and it&#39;s even better if you are using async and await</p><pre>var s3SignedUploadUrl = &quot;...&quot;;<br>var file = document.getElementById(&quot;file-input&quot;).files[0];<br><br>// USE PROMISE<br>uploadS3(s3SignedUploadUrl, file, function(percent) { console.log(percent); })<br>  .then(function() {})<br>  .catch(function() {})<br><br>// USE ASYNC / AWAIT<br>(async () =&gt; {<br>  await uploadS3(s3SignedUploadUrl, file, function(percent) { <br>    console.log(percent); <br>  })<br>})();</pre><p>Brought to you by <a href="https://www.uploadbtn.com/">Uploadbtn</a>. The easiest way to upload files to Amazon S3 without a server. Get started uploading files in just 5 minutes</p><p><em>Originally published at </em><a href="https://www.uploadbtn.com/article/tracking-file-upload-progress-to-amazon-s3-from-browser"><em>www.uploadbtn.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=71be6712c63d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating a file CDN using Amazon S3 and Cloudfront]]></title>
            <link>https://medium.com/@cpatarun/creating-a-file-cdn-using-amazon-s3-and-cloudfront-5d99bbc59153?source=rss-69e634ae51c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/5d99bbc59153</guid>
            <category><![CDATA[amazon-s3]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[amazon-cloudfront]]></category>
            <category><![CDATA[cdn]]></category>
            <dc:creator><![CDATA[UploadBtn]]></dc:creator>
            <pubDate>Wed, 20 Mar 2019 03:05:41 GMT</pubDate>
            <atom:updated>2019-03-20T03:05:41.176Z</atom:updated>
            <content:encoded><![CDATA[<p>Amazon S3 is a file storage platform allowing you to reliably host and serve files to the world. It excels at doing this what a huge array of features at your disposal. However, it’s often not the best choice to serve content to users directly from your S3 bucket if your focus is on performance. The reason is that S3 doesn’t function like a CDN (content delivery network) does.</p><h3>Why serve files from a CDN instead of S3</h3><p>A CDN works to cache copies of your files all around the world and serve it to end users in the shortest time possible. It can also apply numerous other optimisations such as automatic file compression which can dramatically reduce the size of files.</p><h3>What files should be served from a CDN</h3><p>With that in mind, any performance critical files should ideally be served through a CDN such as Amazon Cloudfront instead of directly from your S3 bucket. When it comes to normal websites, you may want to serve the following content through a CDN:</p><ul><li>Images</li><li>Javascript files</li><li>CSS files</li><li>Small static files</li></ul><p>That being said, any kind of non performance critical files, such as downloading a desktop application can be served directly from S3 as performance is not critical in this case. It just needs to download at a reasonable pace and people will be happy.</p><h3>Setup Cloudfront to serve files from S3</h3><p>Assuming you already have an S3 bucket ready to go, the process is pretty straight forward.</p><ol><li>In your AWS console, navigate to “Services &gt; Cloudfront”</li><li>Press the “Create Distribution” button</li><li>Click on the first field “Origin Domain Name” and you will be able to select from your available S3 buckets</li><li>Configure the rest of the settings based on your preferences</li><li>It&#39;s highly recommended you enable “Compress Objects Automatically” to enable GZIP compression</li><li>Create the distribution and let it set itself up</li><li>Once created you will receive a domain name to access your CDN distribution</li></ol><p>Once you have configured a Cloudfront distribution to pull from an S3 bucket, simply access each S3 resource through the same file path via your Cloudfront domain.</p><pre>https://s3.amazonaws.com/&lt;bucket-name&gt;/folder/image.png<br>https://&lt;distribution&gt;.cloudfront.net/&lt;bucket-name&gt;/folder/image.png</pre><p>Brought to you by <a href="https://www.uploadbtn.com/">Uploadbtn</a>. The easiest way to upload files to Amazon S3 without a server. Get started uploading files in just 5 minutes</p><p><em>Originally published at </em><a href="https://www.uploadbtn.com/article/creating-a-file-cdn-using-amazon-s3-and-cloudfront"><em>www.uploadbtn.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5d99bbc59153" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setup a public Amazon S3 bucket with programmatic access]]></title>
            <link>https://medium.com/@cpatarun/setup-a-public-amazon-s3-bucket-with-programmatic-access-f53850124ccf?source=rss-69e634ae51c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/f53850124ccf</guid>
            <category><![CDATA[public-s3]]></category>
            <category><![CDATA[amazon-iam]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[amazon-s3]]></category>
            <dc:creator><![CDATA[UploadBtn]]></dc:creator>
            <pubDate>Wed, 20 Mar 2019 03:03:36 GMT</pubDate>
            <atom:updated>2019-03-20T03:03:36.937Z</atom:updated>
            <content:encoded><![CDATA[<p>In the event you want to serve files from Amazon S3 on your website and allow file uploads from your clients to S3, you will need to configure your bucket in a particular way. This article assumes you already have an Amazon account. If you do not, start by registering for one before proceeding.</p><h3>Create a public S3 bucket</h3><ol><li>Navigate to the S3 service in the Amazon console</li><li>Press “Create Bucket” and enter a name and region</li><li>In the next step, we recommend enabling “Versioning” for extra security to recover from accidental or malicious overwriting of files</li><li>In the next step, under “Manage public bucket policies for this bucket”, un-check both the options below it if you would like public access</li><li>Complete the bucket creation</li><li>Select your new bucket from the bucket list and then click on the “Permissions” tab.</li><li>Select bucket policy and enter the policy below making sure to replace “bucket-name” with your name. This enables public access to all files in your bucket</li></ol><pre>{<br>    &quot;Version&quot;: &quot;2012-10-17&quot;,<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Sid&quot;: &quot;AddPerm&quot;,<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Principal&quot;: &quot;*&quot;,<br>            &quot;Action&quot;: &quot;s3:GetObject&quot;,<br>            &quot;Resource&quot;: &quot;arn:aws:s3:::bucket-name/*&quot;<br>        }<br>    ]<br>}</pre><h3>Enable programmatic access to S3 bucket</h3><ol><li>Navigate to the IAM service on the Amazon console</li><li>Select “Users” on the left menu and press the “Add user” button in blue</li><li>Enter any username you like. Make sure to enable “Programmatic Access” in the first step</li><li>In the next step, press “Attach existing policies directly”, then search for S3 and select “AmazonS3FullAccess”</li><li>Complete the user creation and at the end, make sure to take note of your “Access Key ID” and “Secret Access Key”</li></ol><h3>Optional: Create a specific user policy just for one S3 bucket</h3><p>For maximum security, it is ideal to create a specific user who can only access one S3 bucket. To do this you will need to create a new IAM policy.</p><ol><li>In the Amazon IAM service console, select “Policies” on the left nav bar and choose “Create policy”</li><li>Under actions, search for “S3”. Under the write access level, you will only need the “PutObject” permission to write files.</li><li>Under resources, select “Specific” and press “Add ARN”. Here you will need to enter your bucket name</li><li>After this, review your settings and complete the policy creation</li><li>Now when creating a user following the step above, simply select your new policy in the permissions step</li></ol><h3>Enabling client-side uploads to S3</h3><p>To enable web browsers to upload objects to your S3 bucket, you will need to white list it in your bucket CORS policy.</p><ol><li>Navigate to your specific S3 bucket and click on the “Permissions” tab</li><li>Next, select “CORS Configuration” and paste in the policy below making sure to use your domain name. Alternatively, you can use “*” to match any domain</li></ol><pre>&lt;CORSConfiguration&gt;<br>&lt;CORSRule&gt;<br>    &lt;AllowedOrigin&gt;https://www.your-domain.com&lt;/AllowedOrigin&gt;<br>    &lt;AllowedMethod&gt;PUT&lt;/AllowedMethod&gt;<br>    &lt;AllowedHeader&gt;*&lt;/AllowedHeader&gt;<br>&lt;/CORSRule&gt;<br>&lt;/CORSConfiguration&gt;</pre><p>Brought to you by <a href="https://www.uploadbtn.com/">Uploadbtn</a>. The easiest way to upload files to Amazon S3 without a server. Get started uploading files in just 5 minutes</p><p><em>Originally published at </em><a href="https://www.uploadbtn.com/article/setup-public-amazon-s3-bucket-with-programmatic-access"><em>www.uploadbtn.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f53850124ccf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Upload files from browser to Amazon S3 with Node.js]]></title>
            <link>https://medium.com/@cpatarun/upload-files-from-browser-to-amazon-s3-with-node-js-f2f697d12d4d?source=rss-69e634ae51c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/f2f697d12d4d</guid>
            <category><![CDATA[amazon-s3]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[browser-upload]]></category>
            <category><![CDATA[file-upload]]></category>
            <dc:creator><![CDATA[UploadBtn]]></dc:creator>
            <pubDate>Wed, 20 Mar 2019 02:57:37 GMT</pubDate>
            <atom:updated>2019-03-20T02:57:37.297Z</atom:updated>
            <content:encoded><![CDATA[<p>This article describes the process of uploading files to Amazon S3 directly from the web browser. Before we get started, you will need to have an Amazon iAM user and S3 bucket created. If you haven’t done so already, you can read <a href="https://www.uploadbtn.com/article/setup-public-amazon-s3-bucket-with-programmatic-access">Creating an Amazon S3 bucket with programmatic access</a></p><p>The process of uploading files is:</p><ol><li>The user selects a file to upload</li><li>Browser requests signed URL from your server to upload the file to S3</li><li>The browser uses signed URL to upload the file to S3</li></ol><h3>Server Setup</h3><p>The first thing we need to do is install our dependencies in our project.</p><pre>npm install --save express aws-sdk</pre><p>Then we can set up our server to respond with the signed URL required to upload files to S3</p><pre>var AWS = require(&quot;aws-sdk&quot;);<br>var express = require(&quot;express&quot;);<br>var app = express();<br>var port = 3000;</pre><pre>// SETUP S3 Instance<br>var S3 = new AWS.S3({<br>  accessKeyId: &quot;IAM_USER_ACCESS_KEY_ID&quot;,<br>  secretAccessKey: &quot;IAM_USER_SECRET_ACCESS_KEY&quot;,<br>  region: &quot;ACCOUNT_REGION&quot;,<br>  sslEnabled: true,<br>});</pre><pre>// SETUP UPLOAD ROUTE<br>app.get(&#39;/upload&#39;, (req, res) =&gt; {<br><br>  var path = req.query.path;<br>  var type = req.query.type;<br><br>  var params = {<br>    Expires: 60,<br>    Bucket: &quot;YOUR BUCKET&quot;,<br>    ACL: &quot;public-read&quot;, // ANY ACL YOU LIKE,<br>    Key: path,<br>    ContentType: type<br>  };<br><br>  S3.getSignedUrl(&quot;putObject&quot;, params, (err, data) =&gt; {<br>    if (err) {<br>      res.status(500).send({ error: true });<br>    }<br>    else {<br>      res.send({ signedUrl: data })<br>    }<br>  });<br><br>});<br><br>// START SERVER<br>app.listen(port);</pre><h3>Client Side Upload</h3><p>Next, in your client-side code, you will need to have a HTML file input to allow users to select files.</p><pre>&lt;input id=&quot;file-input&quot; type=&quot;file&quot;/&gt;</pre><p>With a bit of javascript, we can now grab the files from the input and upload it to S3</p><pre>function uploadFile() {<br><br>  var input = document.getElementById(&quot;file-input&quot;);<br>  var file = input.files[0]; // files is an array by default<br><br>  var path = &quot;/folder/&quot; + file.name;<br>  var type = file.type;<br><br>  var apiUrl = &quot;/upload?path=&quot; + path + &quot;&amp;type=&quot; + type;<br><br>  fetch(apiUrl)<br>    // FETCH THE SINGED CERTIFICATE FOR UPLOAD<br>    .then(function(response) {<br>      return response.json();<br>    })<br>    // UPLOAD FILE TO S3<br>    .then(function(data) {<br>      var signedUrl = data.signedUrl;<br>      var uploadedFileUrl = signedUrl.split(&quot;?&quot;)[0];<br>      return fetch(signedUrl, {<br>        method: &quot;PUT&quot;,<br>        body: file,<br>      });<br>    })<br><br>}</pre><p>That’s all you need to start securely uploading files client-side to Amazon S3. This is just a starting point however, you may want to track upload progress and further secure your file uploads.</p><p>Brought to you by <a href="https://www.uploadbtn.com/">Uploadbtn</a>. The easiest way to upload files to Amazon S3 without a server. Get started uploading files in just 5 minutes</p><p><em>Originally published at </em><a href="https://www.uploadbtn.com/article/upload-files-browser-to-amazon-s3-with-nodejs"><em>www.uploadbtn.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f2f697d12d4d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>