从服务器到客户端文件系统的映像 [英] Svaing Image from Server to client FileSystem

查看:72
本文介绍了从服务器到客户端文件系统的映像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含2列的表(ImageData类型为 varbinary(MAX),类型为 int )。

i想要从数据库读取图像并将其保存在客户端的文件系统中。

i googled但它只是为了如何在客户端的浏览器上显示它们而我不需要它。

任何想法我该怎么做?

服务器上的zip图片并给客户端链接??

i have a table that have 2 columns (ImageData of type varbinary(MAX) and id of type int).
i want to to read images from db and save them in the client's FileSystem.
i googled but it just for how to show them on the client's browser and i don't need it.
any idea how can i do that?
zip images on server and give link to client ??

推荐答案

如果你想使用ZIP并且你认为这对你的用户来说没问题,它肯定会有用。但是您不必为存储在服务器端的文件提供链接。如果需要,可以使用类 System.Net.HttpWebResponse 并使用相应的 ContentType 在运行中进行。请参阅:

http://msdn.microsoft.com /en-us/library/system.net.httpwebresponse.aspx [ ^ ],

http://msdn.microsoft.com/en-us/library/system.web.httpresponse.aspx [ ^ ](参见此处的代码示例),

http://msdn.microsoft.com/en-us/library/system.net.httpwebresponse。 contenttype.aspx [ ^ ]。



如果是ZIP,则为您的内容类型应为application / zip。对于其他类型,请参阅:

http://en.wikipedia.org/wiki/Internet_media_type [ ^ ],

< a href =http://www.iana.org/assignments/media-types> http://www.iana.org/assignments/media-types [ ^ ]。



但是,你的内容不必是ZIP。您仍然可以使用特定的图像类型,但强制保存图像而不是在页面上呈现图像。为此,您应该添加自己的HTTP请求标头,如下所示:

If you want to use ZIP and you think this would be fine for your users, it will certainly work. But you don't have to give a link to the file stored to on the server side. If you want, you can do it on the fly, using the class System.Net.HttpWebResponse with corresponding ContentType. Please see:
http://msdn.microsoft.com/en-us/library/system.net.httpwebresponse.aspx[^],
http://msdn.microsoft.com/en-us/library/system.web.httpresponse.aspx[^] (see the code sample here),
http://msdn.microsoft.com/en-us/library/system.net.httpwebresponse.contenttype.aspx[^].

In case of ZIP, your content type should be "application/zip". For other types, please see:
http://en.wikipedia.org/wiki/Internet_media_type[^],
http://www.iana.org/assignments/media-types[^].

However, your content does not have to be ZIP. You can still use your particular image type, but enforce saving the image instead of rendering it on the page. For this purpose, you should add your own HTTP request header which can look like this:
Content-Disposition: attachment; filename="some-file-name"





中此特定标题没有特殊属性HttpWebRespose 类,因此您需要编写此标头并使用属性添加它 System.Net.HttpWebResponse.Headers

http://msdn.microsoft.com/en-us/library/ system.net.httpwebresponse.headers.aspx [ ^ ]。



-SA



There is no a special property for this particular header in the HttpWebRespose class, so you need to compose this header and add it using the property System.Net.HttpWebResponse.Headers:
http://msdn.microsoft.com/en-us/library/system.net.httpwebresponse.headers.aspx[^].

—SA


这篇关于从服务器到客户端文件系统的映像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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