我有来自Filepicker.io的这张图片:https://www.filepicker.io/api/file/9H-1AxgZTwqct8tjkmkZ
但是当我在浏览器中打开它时,它会直接下载文件,我认为这是因为响应头或其他东西,所以我想知道如何代理它以便我可以像其他图像一样在浏览器中查看它,像这样:https://distilleryimage1.s3.amazonaws.com/84d490a4071811e285a622000a1d039f_5.jpg
答案 0 :(得分:1)
curl -si https://www.filepicker.io/api/file/9H-1AxgZTwqct8tjkmkZ | head
HTTP/1.1 200 OK
Access-Control-Allow-Headers: CONTENT-TYPE, X-NO-STREAM
Access-Control-Allow-Methods: DELETE, GET, HEAD, POST, PUT
Access-Control-Allow-Origin: *
Access-Control-Max-Age: 21600
Cache-Control: public, max-age=315360000, no-transform
Content-Disposition: attachment; filename="中秋福利.jpg"
Content-Type: image/jpeg
Date: Fri, 28 Sep 2012 08:21:45 GMT
Server: gunicorn/0.14.6
Content-Disposition设置为attachment
。如果您代理它,则完全删除该标头或将其设置为inline
。
答案 1 :(得分:0)
虽然vinayr的回答是正确的,但您可以通过将?dl=false
附加到FilePicker URI的末尾来完全避免使用代理。
例如:https://www.filepicker.io/api/file/9H-1AxgZTwqct8tjkmkZ?dl=false
FilePicker Documentation中还有许多其他内容,特别是“使用FPUrls”部分和“检索文件”和“图像转换”小节。
答案 2 :(得分:0)
Github使用https://github.com/atmos/camo代理SSL图像。你可以尝试使用它。您可以将它安装在您的快递应用程序上:
var camo = require('./node_modules/server.js') // you have to strip the server.listen(port) part
app.use('/proxy', camo)