使用SSIS将文件从http站点下载到我的本地文件? [英] Downloading a file from http site to my local file using SSIS?
问题描述
听起来很简单,但事实证明令人头疼.我怎样才能做到这一点 ?我最初的想法是使用bat文件,然后将其作为任务添加到SSIS中.
问题是复制,xcopy或robcopy无法正常工作吗?
robocopy"http://wpcfs.corp.xx.com/xxx/xxx/BEP/xxx/documents/EB%20Bus%20Ops%20Points%20of%20Contact.xlsx""C:\ Imports \" >
有什么想法吗?
如果要从网站下载,则可以使用SSIS脚本通过WebClient,WebRequest或HTTP连接管理器下载文件.有一个非常详尽的示例,可以通过HTTP连接管理器进行下载 Its soounds simple but proving to be a headache . How can i do this ? My initial idea was to use a bat file and then add it as a task in SSIS . Problem is that copy, xcopy or robcopy does not work ? robocopy "http://wpcfs.corp.xx.com/xxx/xxx/BEP/xxx/documents/EB%20Bus%20Ops%20Points%20of%20Contact.xlsx" "C:\Imports\" Any ideas ? If you want to download from a website then you can use a SSIS script to download the files either via WebClient, WebRequest, or through the HTTP Connection Manager. There's a pretty thorough example of downloading via the HTTP Connection Manager on this blog. The blog comments also includes code that I listed below that downloads the data via WebRequest/WebResponse. You could also use the more straight forward WebClient, but I found I had problems using the WebClient to download really large files that I was able to avoid with the WebRequest/WebResponse approach.
这篇关于使用SSIS将文件从http站点下载到我的本地文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!Imports System.IO
Imports System.Net
Imports System.Text
Imports System.Web
Public Class WebRetrieve
Public Shared Sub Main()
Dim wr As HttpWebRequest = CType(WebRequest.Create("https://reports/reports.txt"), HttpWebRequest)
Dim ws As HttpWebResponse = CType(wr.GetResponse(), HttpWebResponse)
Dim str As Stream = ws.GetResponseStream()
Dim inBuf(100000000) As Byte
Dim bytesToRead As Integer = CInt(inBuf.Length)
Dim bytesRead As Integer = 0
While bytesToRead > 0
Dim n As Integer = str.Read(inBuf, bytesRead, bytesToRead)
If n = 0 Then
Exit While
End If
bytesRead += n
bytesToRead -= n
End While
Dim fstr As New FileStream("c:\New\reports.txt", FileMode.OpenOrCreate, FileAccess.Write)
fstr.Write(inBuf, 0, bytesRead)
str.Close()
fstr.Close()
End Sub
End Class