我的 django 应用程序可以充当标头剥离代理吗?

发布于 2024-10-17 15:13:35 字数 163 浏览 5 评论 0原文

公共 Soundcloud 曲目 url 通过利用 Content-Disposition 标头(我认为..)在浏览到它们时强制下载,这会触发已知 mime 类型的下载。有没有办法代理(为其创建直通)这些网址并从我的请求中删除此标头。我想避免自己提供 mp3,但我不想触发下载。

Public Soundcloud track urls force a download upon browsing to them by utilizing a Content-Disposition header (I think.. ) which triggers a download for a known mime-type. Is there a way to proxy (create a passthrough for) these urls and strip this header from my request. I want to avoid serving the mp3 myself but I don't want to trigger a download.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

娇纵 2024-10-24 15:13:35

从技术上讲,您完全有可能从服务器请求文件并将传入数据连接到您视图中的输出流响应,从而允许您控制客户端浏览器接收的标头,以便它不会要求它们保存文件。

但出于几个原因,我会建议不要这样做。

  1. 您提到您不想自己提供文件。从技术上讲,在这种情况下您正在提供文件,只是没有存储它。
  2. 这可能是相当昂贵的资源。尤其是网络带宽。您与用户共享的每个 mp3 文件对您来说都将是一种双重打击。您每次都将下载和上传整个文件。您可以在请求 mp3 文件后对其进行缓存,但这样您不仅可以提供该文件,还可以存储该文件。
  3. 文件来源可能不希望您这样做,如果他们发现风声,可能会向您发送停止信函。如果他们提供了一种机制让您在您的网站上分享他们的媒体,他们通常会制定您无法规避的条款和条件。

Technically it is entirely possible that you could request the file from the server and connect that incoming data to an output stream response in your view, thereby allowing you to control the headers that your client's browser receives so that it does not ask them to save the file.

I'm going to recommend against this though for a couple of reasons.

  1. You mentioned you didn't want to serve the files yourself. Technically you are serving the file in this case, you just aren't storing it.
  2. This can be fairly expensive resource wise. Especially network bandwidth. Every mp3 file you share with your user is going to be a sort of double-ding for you. You are going to be both downloading and uploading that entire file, every time. You could cache the mp3 file once it's been requested, but then you aren't just serving the file, you're storing it as well.
  3. The file source likely does not want you to do this and could send you a cease and desist letter if they catch wind of it. If they provide a mechanism for you to share their media on your site, they usually have Terms and Conditions that you cannot circumvent that.
笔芯 2024-10-24 15:13:35

我认为这是不可能的。它应该已经完全取决于浏览器。例如,Opera 会要求用户天气来打开或下载。

您可以使用其嵌入代码将它们嵌入到您的网站中。

编辑:
不,您甚至无法使用标题提供的链接,因为它们已经解决了热链接问题。每次下载都与浏览器/会话相关联,因此您无法存储 mp3 的真实 URL 和链接。

I don't think it's possible. It should already be entirely up to the browser. For example Opera asks user weather to open it or download.

You could embed them in your site using their Embeded Code.

EDIT:
Nope you can't even use the link provided by the header since they've worked around hotlinking. Each download is associated to the browser/session so you can't store the real url for the mp3 and link to that.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文