JSP上传和下载视频 [英] JSP Uploading and downloading Video
问题描述
我想设计一个允许管理员下载和上传视频的网站。有人可以指导我怎么做吗?是否与上传和下载图像相同?任何网站都有示例?
上传可以以相同的方式完成。您基本上只需要在服务器端使用 InputStream
,然后将其写入您想要的任何 OutputStream
例如 FileOutputStream
将其存储在本地磁盘文件系统中。下载基本上也是一样的,您只需要相应地更改 Content-Type
头来表示正确的内容类型,以便浏览器知道该怎么做。 / p>
处理文件上传一个Servlet可以通过 Apache Commons FileUpload 。 这是一个基本例子。可以通过获取文件作为 InputStream
并将其写入响应的 OutputStream
的Servlet的帮助来进行下载。通常的Java IO方式。 这是一个基本的例子。
I want to design a website that allows an admin to download and upload video. Can anyone guide me how to do it? Is it same as upload and download image? Any site have example?
Uploading can be done the same way. You basically just need to end up with an InputStream
in the server side which you then write to any OutputStream
you want, e.g. FileOutputStream
to store it at local disk file system. Downloading is basically also the same way, you only need to change the Content-Type
header accordingly to represent the correct content type so that the browser knows what to do with it.
Processing the file upload a Servlet can be done easy with help of Apache Commons FileUpload. Here's a basic example. Downloading can be done easy with help of a Servlet which obtains the file as InputStream
and writes it to OutputStream
of the response the usual Java IO way. Here's a basic example.
这篇关于JSP上传和下载视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!