HttpHandler的检索从另一台服务器下载文件? [英] HTTPHandler to Retrieve Download File from another server?

查看:175
本文介绍了HttpHandler的检索从另一台服务器下载文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想提供下载文件到网站的用户,但希望对用户隐藏文件的URL ......我想一个HttpHandler可以做的伎俩,但有可能检索的文件外部服务器,它传输给用户?

I would like to provide downloadable files to website users, but want to hide the URL of the files from the user... I'm thinking an HTTPHandler could do the trick, but is it possible to retrieve a file from an external server and stream it to the user?

也许有人可以给我如何做到这一点,或点我到它已经做过的资源的提示吗?

Perhaps somebody can give me a hint at how to accomplish this, or point me to a resource where it's been done before?

只是为了阐述我想要实现......我要建一个ASP.NET网站,其中包含了音乐下载链接。我要保护的文件的实际的URL,我也想将它们存储在外部(PHP)服务器上(非常非常便宜)...

Just to elaborate on what I'm trying to achieve... I'm building an ASP.NET website, which contains a music download link. I want to protect the actual URLs of the file, and I also want to store them on an external (PHP) server (MUCH MUCH cheaper)...

所以我需要做的是建立能够从URL抓取文件流(点到另一台服务器),并且它传输到Response对象,而无需用户意识到它是从另一台服务器来了。

So what I need to do is set up a stream that can grab the file from a URL (points to another server), and stream it to the Response object without the user realising it's coming from another server.

请问的TransmitFile方法允许一个文件的流从一个完全独立的服务器?我不希望到我的服务器的流式传输的文件,因为这违背了目的(节省带宽)......我想在客户端(浏览器),从其他服务器下载文件直接。

Will the TransmitFile method allow streaming of a file from a completely separate server? I don't want the file to be streamed "through" my server, as that defeats the purpose (saving bandwidth)... I want the client (browser) to download the file direct from the other server.

我是否需要在托管服务器或者文件的处理程序?也许在另一端的PHP脚本是要走的路...?

Do I need a handler on the file hosting server perhaps? Maybe a PHP script on the other end is the way to go...?

推荐答案

通过您想要澄清的带宽来自外部服务器,不是你的,它改变的问题还真不少。

With your clarification of wanting the bandwidth to come from the external server and not yours, it changes the question quite a bit.

为了实现这个目标,外部服务器必须有它一个网站,你可以在用户发送至。你无法通过您的网站流的文件,但没有被击中的带宽,或者从您的网站进行控制,而是通过其他的服务器流式传输,所以它必须通过其他站点被完全处理。这一问题是正常的基于URL的方法将显示用户的URL,你说的是,它不显示的URL的第二个要求。

In order to accomplish that, the external server would have to have a website on it you could send the user to. You cannot stream the file through your site but not get hit with the bandwidth, or control it from your site but streamed through the other server, so it must be completely handled through the other site. Problem with that is a normal URL based approach would show the user the URL, which you said is the second requirement that it not show the URL.

但是,不能你刚才有一个服务于外部站点的文件,对哪个文件流将通过从页面上原址后传递细节的通用页面?这将移除指向一个特定的文件的URL。它会显示领域,但用户将无法拉文件,而无需知道后场。

But, couldn't you just have a generic page that serves the files on the external site, and the specifics on which file to stream would be passed through a post from the page on the original site? That would remove the URL pointing to a specific file. It would show the domain, but users would not be able to pull files without knowing the post fields.

这并不需要是一个HttpHandler,只是一个正常的页面。

This would not need to be an HTTPHandler, just a normal page.

这篇关于HttpHandler的检索从另一台服务器下载文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆