简体   繁体   English

Android浏览器无法从我的Nginx服务器下载图像

[英]Android browser can not download image from my nginx server

I have a nginx server(1.2.4) , it provides some images to download. 我有一个nginx服务器(1.2.4) ,它提供了一些要下载的图像。 However, I did not put these file in public folder as I want to do some authentication or something else. 但是,我没有将这些文件放在公用文件夹中,因为我想进行一些身份验证或其他操作。

I use X-Accel-Redirect feature of nginx for these static files. 我用X-Accel-Redirect的功能nginx这些静态文件。 Now I can download there images from desktop browser, so I think I have configure the nginx right. 现在我可以从桌面浏览器下载图像,所以我认为我已经正确配置了nginx。

However, when I use android device, I can not download those files. 但是,当我使用android设备时,无法下载这些文件。 Android always show me "download unsuccessfully" with a "untitled name". Android总是向我显示“下载失败”和“未命名名称”。 I change Content-Disposition to "inline", then I can see the image in browser, so I think the data has been sent to device. 我将Content-Disposition更改为“ inline”,然后可以在浏览器中看到图像,因此我认为数据已发送到设备。

I do not know why android device can not download successfully even the data has been sent. 我不知道为什么即使发送了数据,Android设备也无法成功下载。

Another things is if I just put the image files in "public" folder, let android device directly download there, android device will work correctly, it can download images. 另一件事是,如果我只是将图像文件放在“ public”文件夹中,则让android设备直接下载到那里,android设备将可以正常工作,它可以下载图像。

So, if I use nginx X-Accel-Redirect feature to provice images, android can not download even data has been sent, if I just put them in public folder, android browser can download. 因此,如果我使用nginx X-Accel-Redirect功能提供图像,即使发送了数据,android也无法下载,如果我将它们放在公用文件夹中,则android浏览器可以下载。

please help me to fix this. 请帮助我解决此问题。

I've read somewhere that this is because Android has a "bug" that requires metadata for any downloaded file. 我在某处读到这是因为Android有一个“错误”,该错误需要任何下载文件的元数据。 So we should configure nginx to give the metadata depending on the type of file (pdf, xls, and so on, except web as html/php and so on) 因此,我们应该配置nginx以便根据文件类型(pdf,xls等)提供元数据,但Web作为html / php等除外)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM