I’m Thanh Nguyen Hoang, but you can call me Frank — it’s my English name. Some people online know me as hthanh12.
I’m a web developer who loves building things for the web. Here, I share what I’ve learned about coding, technology, and life.
I’m Thanh Nguyen Hoang, but you can call me Frank — it’s my English name. Some people online know me as hthanh12.
I’m a web developer who loves building things for the web. Here, I share what I’ve learned about coding, technology, and life.
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: file-type library → detect MIME from buffer Linux file command → detect MIME from file path Both methods work well—but not for the same scenarios. This guide shows you the differences, the performance impact, and a best-practice hybrid method using the 5MB rule. ...
🚀 Optimizing Video Uploads: Multipart Upload, Pre-Signed URLs, and S3 Events Uploading big video files is like trying to send a watermelon through a straw 🍉 — it’s slow, clunky, and often ends in frustration. But fear not! With AWS S3, pre-signed URLs, and multipart uploads, we can make uploads as smooth as butter on a warm pancake 🥞. In this post, I’ll show how to: Use Pre-signed URLs for secure direct uploads Enable Multipart Upload for speed and reliability Trigger S3 Events for post-processing And add structured logs to know exactly what’s happening — even when the servers are pretending everything’s fine 😅 🧱 1. Why Pre-Signed URLs? Uploading directly to your backend is like sending every file through one poor server who’s already overworked. Instead, let S3 handle it directly — your server just gives the client a ticket (the pre-signed URL). ...
🧠 Introduction When working with Amazon S3, two common commands developers use are HeadObjectCommand and GetObjectCommand. At first glance, they might seem similar — both retrieve object information — but they serve different purposes. Let’s explore how they differ and when to use each. ⚙️ HeadObjectCommand HeadObjectCommand retrieves only the metadata of an S3 object, without downloading the file content. This is ideal when you just want to: Check if a file exists. Get metadata (like Content-Type, Content-Length, Last-Modified, ETag, etc.). Verify object accessibility or permissions. ✅ Example import { S3Client, HeadObjectCommand } from "@aws-sdk/client-s3"; const s3 = new S3Client({ region: "ap-southeast-1" }); async function checkFileInfo() { try { const command = new HeadObjectCommand({ Bucket: "my-bucket", Key: "example/data.json", }); const response = await s3.send(command); console.log("✅ Object found:", response); } catch (err) { if (err.name === "NotFound") { console.log("❌ Object not found"); } else { console.error("⚠️ Error:", err); } } } checkFileInfo(); 💡 Output (sample) { "AcceptRanges": "bytes", "LastModified": "2025-10-31T02:45:10.000Z", "ContentLength": 24987, "ContentType": "application/json", "ETag": "\"d41d8cd98f00b204e9800998ecf8427e\"" } 👉 No file data is returned — only metadata. ...
When you watch a crisp 4K video online, it’s easy to forget how much math, motion analysis, and trickery are happening behind the scenes. Every second of video is a negotiation between bits, motion, and your eyes — and the deal is never perfect. 🎞️ The Real Job of a Codec A video codec (like H.264, HEVC, or AV1) doesn’t just compress video — it tries to predict what your eyes will notice. It keeps what’s important and throws away what you probably won’t see. ...
Have you ever uploaded a file and the browser didn’t open it correctly — maybe it downloaded instead of showing up on the screen? That usually happens because of something called a MIME type. 🧠 What Is a MIME Type? A MIME type (short for Multipurpose Internet Mail Extensions) tells the browser what kind of file it’s dealing with. For example: File Type MIME Type Extension HTML page text/html .html CSS file text/css .css JavaScript file application/javascript .js JPEG image image/jpeg .jpg, .jpeg PDF document application/pdf .pdf Word document application/vnd.openxmlformats-officedocument.wordprocessingml.document .docx When your web server sends a file, it includes a header like this: ...