Downloading a file over HTTP using SSIS
By ashvinis
Published: 12/30/2005
Reader Level: Beginner Intermediate
Rated: 4.67 by 3 member(s).
Tell a Friend
Rate this Article
Printable Version
Discuss in the Forums

A question came up on an internal alias about how can one download a file over HTTP. Here's a script that does that, should be trivial to wrap it inside a task if you forsee doing this over and over again.

Imports System.Net

Public Sub Main()

Dim myWebClient As WebClient

Dim remoteUri As String

Dim localFileName As String

Dim fireAgain As Boolean

Try

myWebClient = New WebClient()

' get the context from variables

remoteUri = CStr(Dts.Variables("RemoteUri").Value)

localFileName = CStr(Dts.Variables("LocalFileName").Value)

' tell the user what we're downloading where

Dts.Events.FireInformation(0, String.Empty, String.Format("Downloading '{0}' from '{1}'", localFileName, remoteUri), String.Empty, 0, fireAgain)

' do the actual download

myWebClient.DownloadFile(remoteUri, localFileName)

Dts.TaskResult = Dts.Results.Success

Catch ex As Exception

' post the error message we got back.

Dts.Events.FireError(0, String.Empty, ex.Message, String.Empty, 0)

Dts.TaskResult = Dts.Results.Failure

End Try

End Sub

 


More information can be found here:
Ashvini Sharma: A SQL Server Integration Services Blog
SSIS: Downloading a file over HTTP



Marketplace
(Sponsored Links)
What are the green links?
   



 
Copyright 2007 CMP Tech LLC | Hosted By SecureWebs.com
Privacy Policy (4/10/06) | Your California Privacy Rights (4/10/06) | Terms of Service | Advertising Info | About Us | Help