Tip – How to check file size before download from URL

Introduction

In this article you will see how to use SSIS REST API Task to get file size without actually downloading it.

 

 

 

Prerequisites

Before we look into Step-By-Step section to get file size from URL let’s make sure you met following requirements.

  1. SSIS designer installed. Sometimes it is referred as BIDS or SSDT (download it from Microsoft site).
  2. Basic knowledge of SSIS package development using Microsoft SQL Server Integration Services.
  3. ZappySys SSIS PowerPack installed. Click on the link to download.

Configure SSIS REST API Task to Get file size from URL

Now lets look at how to get file size from URL

  1. Open SSIS Package and goto Control Flow designer
  2. Create new SSIS variable call it ContentSizeInBytes
  3. Drag and drop ZS REST API Task from SSIS Toolbox
  4. Double click API Task to configure. Enter following
    1. Enter File URL you like to download
    2. Change default method from GET to HEAD
  5. Click Test. Review Content-Length header in Response. That’s what we need to save to Variable
  6. Now go to Response Settings tab as below and Configure Content-Length Header mapping. If its not showing in the Grid then most likely your Web Server doesn’t support HEAD command and there may be some other method you have to use. For now we will assume just like most of Web Servers your API also supports HEAD command.
  7. Here is the screenshot of actual configuration on Response Tab
Posted in SSIS REST API Task, SSIS Tips & How-Tos and tagged , , .