<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>CDN on seth-shi</title><link>https://sethix.com/tags/cdn/</link><description>Recent content in CDN on seth-shi</description><generator>Hugo -- gohugo.io</generator><language>en</language><lastBuildDate>Thu, 23 Apr 2020 18:56:21 +0800</lastBuildDate><atom:link href="https://sethix.com/tags/cdn/index.xml" rel="self" type="application/rss+xml"/><item><title>Method for Batch Downloading and Packaging Files from Remote URLs</title><link>https://sethix.com/posts/2020042318/</link><pubDate>Thu, 23 Apr 2020 18:56:21 +0800</pubDate><guid>https://sethix.com/posts/2020042318/</guid><description>Background Recently encountered a problem during code refactoring: needing to batch download and package a set of images from OSS The old server directly mounted OSS to the filesystem, using Linux commands for copying and packaging (fast but incompatible with the new server architecture) OSS doesn&amp;rsquo;t provide direct packaging APIs (Qiniu Cloud supports this) Solutions Considered Discarded PHP backend fetching images to memory for packaging (memory overload risk with AI/PSD files) Discarded PHP backend saving images to disk for packaging (slow fetching and processing for large files) Implemented Frontend solution: JS fetches file info from backend, asynchronously downloads resources, and packages them client-side Prerequisites CORS configuration: Requires adding cross-origin headers on OSS/resource server CDN bypass: Configure a dedicated domain without CDN acceleration (skip if not using CDN) Implementation Steps Use JSZip library for client-side zip operations Utilize JSZip-utils for handling remote resource fetching Core implementation logic: &amp;lt;!</description></item></channel></rss>