私が取り組んでいるプロジェクトでは、ftp アクセスしかできないファイルへの http アクセスを提供する必要があります。これは、ファイルをダウンロードする必要があるが http のみをサポートする外部サービスとして使用されます。以下のコードを試してみましたが、CPU/メモリの使用率が非常に高く、ゆっくりと死んでいきます。助言がありますか?
using System;
using System.Web;
using System.Net;
using System.IO;
public class ftpproxy : IHttpHandler
{
// ftpproxy.ashx?src=ftp://username:password@server.com/staticfiles/foo.f4v
public void ProcessRequest (HttpContext context) {
WebClient wc = new WebClient();
string src = context.Request.QueryString["src"];
using (Stream instr = wc.OpenRead(src))
{
instr.CopyTo(context.Response.OutputStream);
}
}
public bool IsReusable {
get {
return false;
}
}
}
ありがとうございました!
ああ、これらは大きなファイルです (数百メガから数ギガバイト)。