<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Posts on hthanh12's blog</title><link>https://hthanh12.github.io/posts/</link><description>Recent content in Posts on hthanh12's blog</description><generator>Hugo -- 0.152.2</generator><language>en-us</language><lastBuildDate>Sat, 22 Nov 2025 01:02:36 +0700</lastBuildDate><atom:link href="https://hthanh12.github.io/posts/index.xml" rel="self" type="application/rss+xml"/><item><title>How to Detect MIME Types in Node.js: `file-type` vs Linux `file` (and the 5MB Rule)</title><link>https://hthanh12.github.io/posts/detect-mimetype/</link><pubDate>Sat, 22 Nov 2025 01:02:36 +0700</pubDate><guid>https://hthanh12.github.io/posts/detect-mimetype/</guid><description>&lt;p&gt;Detecting the correct MIME type is critical when processing uploads, generating thumbnails, validating content, or securing your storage pipeline. In Node.js, developers usually choose between two common approaches:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;file-type&lt;/code&gt; library&lt;/strong&gt; → detect MIME from &lt;strong&gt;buffer&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Linux &lt;code&gt;file&lt;/code&gt; command&lt;/strong&gt; → detect MIME from &lt;strong&gt;file path&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Both methods work well—but &lt;em&gt;not&lt;/em&gt; for the same scenarios.&lt;br&gt;
This guide shows you the differences, the performance impact, and a &lt;strong&gt;best-practice hybrid method using the 5MB rule&lt;/strong&gt;.&lt;/p&gt;</description></item><item><title>Optimizing Video Uploads: Multipart Upload, Pre-Signed URLs, and S3 Events</title><link>https://hthanh12.github.io/posts/upload-video/</link><pubDate>Fri, 07 Nov 2025 22:09:19 +0700</pubDate><guid>https://hthanh12.github.io/posts/upload-video/</guid><description>How to build a scalable, reliable video upload system using AWS S3, pre-signed URLs, multipart uploads, and S3 event triggers — with structured logging best practices (and a sprinkle of developer humor).</description></item><item><title>HeadObjectCommand vs GetObjectCommand in AWS SDK</title><link>https://hthanh12.github.io/posts/headobject-vs-getobject/</link><pubDate>Thu, 06 Nov 2025 23:40:28 +0700</pubDate><guid>https://hthanh12.github.io/posts/headobject-vs-getobject/</guid><description>Understand the difference between HeadObjectCommand and GetObjectCommand in AWS SDK for JavaScript (v3).</description></item><item><title>The Secret Trade-Off in Video Compression: Bits, Motion, and Human Vision</title><link>https://hthanh12.github.io/posts/the-secret-trade-off-in-video/</link><pubDate>Sun, 02 Nov 2025 16:56:43 +0700</pubDate><guid>https://hthanh12.github.io/posts/the-secret-trade-off-in-video/</guid><description>A deep look at how video codecs balance bits, motion, and human vision.</description></item><item><title>Understanding MIME Types and File Extensions</title><link>https://hthanh12.github.io/posts/my-first-post/</link><pubDate>Thu, 30 Oct 2025 16:45:00 +0000</pubDate><guid>https://hthanh12.github.io/posts/my-first-post/</guid><description>&lt;p&gt;Have you ever uploaded a file and the browser didn’t open it correctly — maybe it downloaded instead of showing up on the screen?&lt;br&gt;
That usually happens because of something called a &lt;strong&gt;MIME type&lt;/strong&gt;.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="-what-is-a-mime-type"&gt;🧠 What Is a MIME Type?&lt;/h2&gt;
&lt;p&gt;A &lt;strong&gt;MIME type&lt;/strong&gt; (short for &lt;em&gt;Multipurpose Internet Mail Extensions&lt;/em&gt;) tells the browser what kind of file it’s dealing with.&lt;br&gt;
For example:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;File Type&lt;/th&gt;
&lt;th&gt;MIME Type&lt;/th&gt;
&lt;th&gt;Extension&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;HTML page&lt;/td&gt;
&lt;td&gt;&lt;code&gt;text/html&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;.html&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CSS file&lt;/td&gt;
&lt;td&gt;&lt;code&gt;text/css&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;.css&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;JavaScript file&lt;/td&gt;
&lt;td&gt;&lt;code&gt;application/javascript&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;.js&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;JPEG image&lt;/td&gt;
&lt;td&gt;&lt;code&gt;image/jpeg&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;.jpg&lt;/code&gt;, &lt;code&gt;.jpeg&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PDF document&lt;/td&gt;
&lt;td&gt;&lt;code&gt;application/pdf&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;.pdf&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Word document&lt;/td&gt;
&lt;td&gt;&lt;code&gt;application/vnd.openxmlformats-officedocument.wordprocessingml.document&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;.docx&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;When your web server sends a file, it includes a header like this:&lt;/p&gt;</description></item></channel></rss>