Image
来源:互联网 发布:java文件下载原理 编辑:程序博客网 时间:2024/05/17 04:25
package resource.recommendation;import enums.MyPathManager;import util.file.SaveImage;import javax.activation.MimetypesFileTypeMap;import javax.servlet.ServletContext;import javax.servlet.http.HttpServletRequest;import javax.ws.rs.*;import javax.ws.rs.core.Context;import javax.ws.rs.core.MediaType;import javax.ws.rs.core.Response;import java.io.File;import java.io.IOException;/** * Created by liker on 05/08/2015 0005. * Group iTailor.hunters.neu.edu.cn */@Path("imageServer")public class ImageService { @GET @Produces("image/*") public Response getImage(@QueryParam("accountID") final int accountID, @QueryParam("imageID") final String imageName, @HeaderParam("password") final String password) { File file = new File("../images/" + imageName); if (!file.exists()) { throw new WebApplicationException(404); } String mt = new MimetypesFileTypeMap().getContentType(file); return Response.ok(file, mt).header("ContentType", "image/*").build(); } @POST @Consumes(MediaType.APPLICATION_OCTET_STREAM) public boolean postImage(@QueryParam("imageID") final String imageName, @Context HttpServletRequest request, final File f) throws IOException { SaveImage.settleIntoDISK(f, imageName); return true; } @DELETE public boolean deleteImage(@QueryParam("accountID") final int accountID, @QueryParam("imageID") final String imageName, @HeaderParam("password") final String password, @Context ServletContext application) { File file = new File(MyPathManager.imagePath + "/" + imageName); System.out.println(file.getAbsolutePath()); if (!file.exists()) { throw new WebApplicationException(404); } else { file.delete(); return true; } } @PUT public boolean putImage(@QueryParam("accountID") final int accountID, @QueryParam("imageID") final String imageName, @HeaderParam("password") final String password, final File f) { SaveImage.settleIntoDISK(f, imageName); return true; }}
0 0
- Image
- Image
- Image
- Image
- image
- image
- image
- image
- Image$$
- Image
- image
- image
- Image
- image
- Image
- image
- Image debugger
- image jpeg
- 同态滤波(Homomorphic filtering)
- 值得阅读的android技术文章
- 将等号作为键值的js字符串转json
- 设计模式之策略模式
- 平台使用
- Image
- UICollectionView
- android从应用到驱动之—camera(1)---程序调用流程
- 安装 Windows XP
- 试一下
- 【JS设计模式】JavaScript特性
- 8.17
- Linux记录
- [资金流入流出预测]一点心得、一份攻略、一段baseline code —— I'm PLUS