如何将Windows Azure存储Blob发送到具有已更改标头的浏览器 [英] How to send Windows Azure Storage blob to browser with changed header

查看:70
本文介绍了如何将Windows Azure存储Blob发送到具有已更改标头的浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

情况:我有大量的视频和图像以及小型的Play应用程序,这些应用程序将对Blob的引用存储在DB中.对于可以正常使用的网络,我渲染页面,在其中放置Flowplayer,并在配置中使用直接Blob的路径作为源视频.无论如何,我都被要求为其他较旧的设备提供其他可能性-这些设备应直接在标头中通过响应头发送文件:

Situation: I have a large set of videos and images and small Play applications, which stores references to the blobs in DB. For web usage that's OK, I'm rendering page, where I put Flowplayer and in it's config I'm using direct blob's path as a source video. Anyway I was asked for additional possibility for other older devices - which should send the file in the response body directly with headers:

Content-Type:video/mp4
Content-disposition:inline
Content-Transfer-Encoding:binary

最初,该解决方案是使用PHP脚本完成的,该脚本使用CURL将blob提取到服务器,并作为对带有可操作标头的客户端的响应返回.

Originally that solution was done with PHP script, which fetched the blob to the server with the CURL and returned as a response to the client with manipulated header.

问题:用Play做到这一点的最佳方法是什么? (最好不要将文件下载到服务器). Blob将是公共的,因此我不需要关心隐藏原始路径,只需要添加上面提到的标头即可.

Question: What is the best way to do that job with Play? (preferably without downloading file to the server). Blobs will be public, so I don't need to care about hiding original paths, I just need to add headers mentioned above.

  1. 是否应该使用WS.url()将文件提取到服务器并以带有修改后的标头的Result形式发送?我试过了,但是WS超时有一些问题.
  2. 也尝试设置标头Content-Location:http//mystorage...,因为据我了解,它仍然需要响应正文中的文件.因此,也许还有其他一些仅使用标头的技术.
  3. 有什么方法可以在返回直接Blob时强制使用自定义标头(即,通过在GET参数中进行设置)吗?
  1. Should I use WS.url() to fetch the file to the server and send it as a Result with modified headers? I tried this, but had some problems with WS timeouts.
  2. Also tried to set the header Content-Location:http//mystorage..., anyway as I understood it requires file in the response body anyway. So maybe there is some other technique with usage of the headers only.
  3. Is there any way to force custom headers while returning direct blob (ie. by setting it in the GET params) ?

也许还有其他方法?

推荐答案

我解决了方法No的问题. 1,但使用java.net.URL代替WS.url()

I solved my problem with approach no. 1, but with usage of java.net.URL instead of WS.url(),

对于更好的主张(特别是如果无需将文件下载到服务器即可完成),赏金承诺是切实可行的.

Bounty promise is actual for better propositions (especially, if it will be done without downloading file to the server).

这篇关于如何将Windows Azure存储Blob发送到具有已更改标头的浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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