<?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 Hasith Methmal on Medium]]></title>
        <description><![CDATA[Stories by Hasith Methmal on Medium]]></description>
        <link>https://medium.com/@hasithmethmal?source=rss-675f12fca3eb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*CkFrX8NSDlNdfeGp9vmSbw.jpeg</url>
            <title>Stories by Hasith Methmal on Medium</title>
            <link>https://medium.com/@hasithmethmal?source=rss-675f12fca3eb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 17:19:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hasithmethmal/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[How to Zip a file in JavaScript and Unzip in .NET API]]></title>
            <link>https://medium.com/theleanprogrammer/how-to-zip-a-file-in-javascript-and-unzip-in-net-api-dddc3bd498f7?source=rss-675f12fca3eb------2</link>
            <guid isPermaLink="false">https://medium.com/p/dddc3bd498f7</guid>
            <category><![CDATA[c-sharp-programming]]></category>
            <category><![CDATA[net-core]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[zip]]></category>
            <dc:creator><![CDATA[Hasith Methmal]]></dc:creator>
            <pubDate>Sat, 22 May 2021 22:30:54 GMT</pubDate>
            <atom:updated>2021-06-13T07:29:42.273Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to Zip a file in JavaScript and Unzip in .NET API via POST</h3><h4>Let’s make the network requests more efficient ;)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hB_ma6-_e3ISEAWmlEx8vw.png" /></figure><p>As an engineer, there can be a lot of times when you might come across a situation where you have to upload a large file from your JavaScript environment and send it over to your API via a POST request.</p><p>Sending large chunks of data in a POST request might be tricky. That’s when Zip comes to the rescue. This article will walk you through how to Zip up a large (or any size for that matter) file and send it to your .NET Core API and unzip the data for you to use.</p><p>Now, let’s get down to business!</p><h3>Using Zip in JavaScript</h3><p>One of the most popular and easiest ways to create a zip archive using JavaScript is to use <a href="https://stuk.github.io/jszip/">JSZip</a>.</p><p>Check out the below code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fa082555a2c394a15a85f455b703c9c5/href">https://medium.com/media/fa082555a2c394a15a85f455b703c9c5/href</a></iframe><p>In the above example, it will compress any file that you pass and will store the compressed file in setUploadData hook (ReactJS). You can call your POST request and use the hook as a parameter to your upload.</p><p>If you’re not using react, you can omit the hook and directly use the result as you please.</p><blockquote>I am not going to show to how to send a POST request in this article as there are countless literature on that you can read.</blockquote><p>Moving on,</p><h3>Unzipping the data in .NET Core Web API</h3><p>Let’s get down to business with .NET Core Web API.</p><blockquote>For this example I am assuming you’re familiar with C# and .NET Core.</blockquote><p>Assume the file which you want to unzip has been received by your WebAPI endpoint and has been parsed to a model of your choice. Here let’s say that our data to be unzipped in a variable called DataPack.</p><p>Refer the below code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dc55fad975b4b32e8d34b9ceed51d6e3/href">https://medium.com/media/dc55fad975b4b32e8d34b9ceed51d6e3/href</a></iframe><p>This code will prepare your DataPack to a C# zip archive so that you will be able to unzip its content using the function given below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/19c1321cda8f7a479a02e5dfb1a67f5e/href">https://medium.com/media/19c1321cda8f7a479a02e5dfb1a67f5e/href</a></iframe><p>The above C# function will unzip your zip archive in no time.</p><p>Note that this example assumes that there is only 1 text file in the zip archive. I leave it up you, the curious learner to find how to modify this function to read multiple files if there are any.</p><p>That’s it for this guide. Happy coding and cheers!</p><p>Don’t forget to follow The Lean Programmer Publication for more such articles, and subscribe to our newsletter <a href="http://tinyletter.com/TheLeanProgrammer">tinyletter.com/TheLeanProgrammer</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dddc3bd498f7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/theleanprogrammer/how-to-zip-a-file-in-javascript-and-unzip-in-net-api-dddc3bd498f7">How to Zip a file in JavaScript and Unzip in .NET API</a> was originally published in <a href="https://medium.com/theleanprogrammer">TheLeanProgrammer</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>