当前位置: 首页>>代码示例>>Java>>正文


Java FormDataContentDisposition.getFileName方法代码示例

本文整理汇总了Java中com.sun.jersey.core.header.FormDataContentDisposition.getFileName方法的典型用法代码示例。如果您正苦于以下问题:Java FormDataContentDisposition.getFileName方法的具体用法?Java FormDataContentDisposition.getFileName怎么用?Java FormDataContentDisposition.getFileName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sun.jersey.core.header.FormDataContentDisposition的用法示例。


在下文中一共展示了FormDataContentDisposition.getFileName方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: uploadFile

import com.sun.jersey.core.header.FormDataContentDisposition; //导入方法依赖的package包/类
/**
    * Returns text response to caller containing current time-stamp
    * @return error response in case of missing parameters an internal exception or
    * success response if file has been stored successfully 
    */
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
   public Response uploadFile(
       @FormDataParam("file") InputStream uploadedInputStream,
       @FormDataParam("file") FormDataContentDisposition fileDetail) {
	
	// check if all form parameters are provided
	if (uploadedInputStream == null || fileDetail == null)
		return Response.status(400).entity("Invalid form data").build();
	
	// create our destination folder, if it not exists
	try {
		createFolderIfNotExists(UPLOAD_FOLDER);
	} catch (SecurityException se) {
		return Response.status(500).entity("Can not create destination folder on server").build();
	}

       String uploadedFileLocation = UPLOAD_FOLDER + fileDetail.getFileName();
       try {
		saveToFile(uploadedInputStream, uploadedFileLocation);
	} catch (IOException e) {
		return Response.status(500).entity("Can not save file").build();
	}

       return Response.status(200).entity("File saved to " + uploadedFileLocation).build();
   }
 
开发者ID:JavaTutorialNetwork,项目名称:Tutorials,代码行数:32,代码来源:FileUploadService.java

示例2: uploadFile

import com.sun.jersey.core.header.FormDataContentDisposition; //导入方法依赖的package包/类
@POST
@Path("/send")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response uploadFile(
	@Context UriInfo info,
	@FormDataParam("file") InputStream uploadedInputStream,
	@FormDataParam("file") FormDataContentDisposition fileDetail,

	@FormDataParam("endpointPath") String endpointPath,
	@FormDataParam("queryParameters") String queryParameters
		) throws URISyntaxException, UnsupportedEncodingException {
	
	
	String uploadedFileLocation = DIRECTORY + fileDetail.getFileName();

	String filePath = new File(uploadedFileLocation).getAbsolutePath();
	
	try {
		
		writeToFile(uploadedInputStream, uploadedFileLocation);
		
	} catch (IOException e) {
		System.out.println("[File Uploader] Error uploading file: "+filePath);
		e.printStackTrace();
	}

	URI pentahoBaseUrl = info.getBaseUri().resolve("../");
	endpointPath = pentahoBaseUrl + endpointPath;
	endpointPath += "?paramfileUrl="+URLEncoder.encode(filePath,"UTF-8")+queryParameters;

	return Response.temporaryRedirect(new URI(endpointPath)).build();
}
 
开发者ID:marpontes,项目名称:oncase-biserver-uploader,代码行数:33,代码来源:UploaderREST.java

示例3: postWSDLParse

import com.sun.jersey.core.header.FormDataContentDisposition; //导入方法依赖的package包/类
@Path("/WSDLParse")
@POST
@Consumes("multipart/form-data")
@Produces("application/json")

public SOAPServiceModel postWSDLParse(@PathParam("accountId") int accountId, @FormDataParam("file") InputStream uploadedInputStream, @FormDataParam("file") FormDataContentDisposition fileDetail)
{
//create a new post<resourceName>Handler
oPOSTWSDLParseHandler = new POSTWSDLParseHandler(accountId,oApplicationUri, uploadedInputStream, fileDetail.getFileName());
return oPOSTWSDLParseHandler.postWSDLParse();
}
 
开发者ID:s-case,项目名称:web-service-annotation-tool,代码行数:12,代码来源:WSDLParseController.java

示例4: postWADLParse

import com.sun.jersey.core.header.FormDataContentDisposition; //导入方法依赖的package包/类
@Path("/WADLParse")
@POST
@Consumes("multipart/form-data")
@Produces("application/json")

public RESTServiceModel postWADLParse(@PathParam("accountId") int accountId, @FormDataParam("file") InputStream uploadedInputStream, @FormDataParam("file") FormDataContentDisposition fileDetail )
{
//create a new post<resourceName>Handler
oPOSTWADLParseHandler = new POSTWADLParseHandler(accountId,oApplicationUri, uploadedInputStream, fileDetail.getFileName());
return oPOSTWADLParseHandler.postWADLParse();
}
 
开发者ID:s-case,项目名称:web-service-annotation-tool,代码行数:12,代码来源:WADLParseController.java

示例5: loadUploadedZippedApplicationTemplate

import com.sun.jersey.core.header.FormDataContentDisposition; //导入方法依赖的package包/类
@Override
public Response loadUploadedZippedApplicationTemplate( InputStream uploadedInputStream, FormDataContentDisposition fileDetail ) {

	this.logger.fine( "Request: load application from an uploaded ZIP file (" + fileDetail.getFileName() + ")." );
	File tempZipFile = new File( System.getProperty( "java.io.tmpdir" ), fileDetail.getFileName());
	Response response;
	try {
		// Copy the uploaded ZIP file on the disk
		Utils.copyStream( uploadedInputStream, tempZipFile );

		// Load the application
		response = loadZippedApplicationTemplate( tempZipFile.toURI().toURL().toString());

	} catch( IOException e ) {
		response = handleError(
				Status.NOT_ACCEPTABLE,
				new RestError( REST_MNGMT_ZIP_ERROR, e ),
				lang( this.manager )).build();

	} finally {
		Utils.closeQuietly( uploadedInputStream );

		// We do not need the uploaded file anymore.
		// In case of success, it was copied in the DM's configuration.
		Utils.deleteFilesRecursivelyAndQuietly( tempZipFile );
	}

	return response;
}
 
开发者ID:roboconf,项目名称:roboconf-platform,代码行数:30,代码来源:ManagementResource.java

示例6: resolvePath

import com.sun.jersey.core.header.FormDataContentDisposition; //导入方法依赖的package包/类
private String resolvePath(FormDataContentDisposition fileDetail) {
    return PropertyManager.getProperty(UPLOAD_RESOURCE_DIRECTORY_PROPERTY) + fileDetail.getFileName();
}
 
开发者ID:oxaoo,项目名称:mingi,代码行数:4,代码来源:FileWriter.java

示例7: newMediaAssetPreviewImage

import com.sun.jersey.core.header.FormDataContentDisposition; //导入方法依赖的package包/类
@PUT
@Path("{id}/media-assets/{mediaAssetId}/preview-image")
@Consumes({ MediaType.MULTIPART_FORM_DATA })
public Response newMediaAssetPreviewImage(@PathParam("id") Id id, @PathParam("mediaAssetId") Id mediaAssetId,
    @FormDataParam("file") InputStream uploadedInputStream,
    @FormDataParam("file") FormDataBodyPart formDataBodyPart) {
    CatalogMediaAsset mediaAsset = null;

    if (id != null && mediaAssetId != null) {
        // Get product and media-asset.
        Product product = checked(service.get(Product.class, id));
        mediaAsset = checked(service.get(CatalogMediaAsset.class, mediaAssetId));

        // Just make sure that the objects match.
        if (product.getId().equals(mediaAsset.getProductId())) {
            FormDataContentDisposition fileDetails = formDataBodyPart.getFormDataContentDisposition();

            String videoSysPath = mediaAsset.getSystemPath();

            if (videoSysPath != null) {
                String absSystemPath = videoSysPath.substring(0, videoSysPath.lastIndexOf(File.separatorChar) + 1)
                    + fileDetails.getFileName();

                File savedFile = catalogMediaHelper.saveToDisk(uploadedInputStream, absSystemPath, product);

                // We need to get the relative path from the saved file in
                // case a version number has been added.
                String relativePath = catalogMediaHelper.toRelativeAssetPath(savedFile.getAbsolutePath());
                mediaAsset.setPreviewImagePath(catalogMediaHelper.toWebURI(relativePath));

                service.update(mediaAsset);
            }
        }
    } else {
        throwBadRequest(
            "ProductId and mediaAssetId cannot be null in requestURI. Expecting: products/{id}/media-assets/{mediaAssetId}/preview-image");
    }

    if (mediaAsset == null || mediaAsset.getId() == null) {
        throwInternalServerError();
    }

    return ok(mediaAsset);
}
 
开发者ID:geetools,项目名称:geeCommerce-Java-Shop-Software-and-PIM,代码行数:45,代码来源:ProductResource.java

示例8: installNewModule

import com.sun.jersey.core.header.FormDataContentDisposition; //导入方法依赖的package包/类
/**
 * Heavily adapted from ModuleUploadServlet written by Jordan Slott
 * 
 * @param uploadedInputStream
 * @param fileDetail
 * @return 
 */
@POST
@Path("/module")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response installNewModule(
        @FormParam("files[]") File file,
        @FormParam("files[]")FormDataContentDisposition info
        ) 
{
     
    ModuleManager manager = ModuleManager.getModuleManager();
    
    String name = info.getFileName();
    System.out.println("file: "+name);
    if(name.endsWith(".jar")) {
        //success
        //parse out the '.jar'
        name = info.getFileName().substring(0,info.getFileName().length() - 4);
    } else {
        //fail
        logger.warning("FILE NOT A MODULE!");
        return Response.status(Status.INTERNAL_SERVER_ERROR).cacheControl(new CacheControl()).build();
    }
    
    File tmpFile = null;
    try {
        tmpFile = File.createTempFile(name+"_tmp", ".jar");
        tmpFile.deleteOnExit();
        RunUtil.writeToFile(new FileInputStream(file), tmpFile);
    } catch(Exception e) {
        logger.warning("ERROR WRITING TO FILE!");
        return Response.status(Status.INTERNAL_SERVER_ERROR).cacheControl(new CacheControl()).build();
    }
    
    
    Collection<File> moduleFiles = new LinkedList<File>();
    moduleFiles.add(tmpFile);
    Collection<Module> result = manager.addToInstall(moduleFiles);
    if(result.isEmpty()) {
        logger.warning("NOTHING IN MODULE!");
        return Response.status(Status.INTERNAL_SERVER_ERROR).cacheControl(new CacheControl()).build();
    }
    
    //We won't use this data on the client side, so pass in dummy data for
    //file size and URL.        
    FileMeta metaData = new FileMeta(tmpFile.getName(), 0, "");
    List<FileMeta> metas = Lists.newArrayList(metaData);
    GenericEntity<List<FileMeta>> entity = new GenericEntity<List<FileMeta>>(metas){};
    return Response.ok(entity).cacheControl(new CacheControl()).build();
}
 
开发者ID:josmas,项目名称:openwonderland,代码行数:57,代码来源:ModuleInstallerResource.java

示例9: upload

import com.sun.jersey.core.header.FormDataContentDisposition; //导入方法依赖的package包/类
/**
 * upload a new content item in the system
 * 
 * @param author
 * @param device
 * @param copyright
 * @param description
 * @param url
 * @param servletRequest
 * @param servletResponse
 * @throws Exception
 */
@PUT
@Path("upload")
@Produces(MediaType.APPLICATION_JSON)
@Consumes({ MediaType.MULTIPART_FORM_DATA,
		MediaType.APPLICATION_OCTET_STREAM })
public String upload(
		@FormDataParam("binary_content") FormDataContentDisposition fileDetail,
		@FormDataParam("binary_content") InputStream uploadedInputStream,
		@FormDataParam("userImage") int userImage,
		@Context HttpServletRequest servletRequest,
		@Context HttpServletResponse servletResponse) throws Exception {

	User u = (User) servletRequest.getSession(true).getAttribute(
			SESSION_VAR_USER);
	/*
	 * TODO: remove mediadir? String mediadir =
	 * servletRequest.getSession().getServletContext()
	 * .getInitParameter("media.dir");
	 */
	String uploadedFileLocation = fileDetail.getFileName();

	// save it
	File[] uploadedFileset = saveToFile(uploadedInputStream,
			uploadedFileLocation, u.getId());

	Logger.log("UserData.upload() File uploaded via Jersey based RESTFul Webservice to: "
			+ uploadedFileLocation);

	if (userImage > 0) {
		String f = fileDetail.getFileName();
		u.setAvatarImage(f);

		SqlSession session = (SqlSession) servletRequest
				.getAttribute(SESSION_VAR_SQLSESSION);
		int rowsUpdated = session.update(
				"io.starter.dao.UserMapper.updateByPrimaryKey", u);

		u = UserData.getUserObjectByID(u.getId(), servletRequest,
				servletResponse);
		u.setAvatarImage(f);

		session.commit();
		if (rowsUpdated < 1)
			throw new ServletException(
					"UserData.upload() could not setAvatarImage()");
	}
	// return Response.status(200).entity(output).build();

	// return the JSON result
	JSONObject j = new JSONObject();

	String fnamey = uploadedFileLocation.substring(0,
			uploadedFileLocation.lastIndexOf("."));
	String fnamex = uploadedFileLocation.substring(uploadedFileLocation
			.lastIndexOf("."));

	String fna = "/" + fnamey + "/Standard" + fnamex;

	fna = fnamey + fnamex;
	j.put("filename", fna);

	j.put("mimeType", servletRequest.getSession().getServletContext()
			.getMimeType(fna));

	return j.toString();
}
 
开发者ID:StarterInc,项目名称:Ignite,代码行数:79,代码来源:ContentData.java


注:本文中的com.sun.jersey.core.header.FormDataContentDisposition.getFileName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。