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


Java UploadedFile.getFileName方法代码示例

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


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

示例1: handleFileUpload

import org.primefaces.model.UploadedFile; //导入方法依赖的package包/类
public void handleFileUpload(FileUploadEvent event) {
	UploadedFile uploadedFile = event.getFile();
	String uploadedFileName = uploadedFile.getFileName();
	StringBuilder tmpFileNameBuilder = new StringBuilder();

	tmpFileNameBuilder.append(System.currentTimeMillis());
	tmpFileNameBuilder.append(".");
	tmpFileNameBuilder.append(FilenameUtils.getExtension(uploadedFileName));
	tmpFileName = tmpFileNameBuilder.toString();
	String tmpFilePath = getTmpFilePath();

	try {
		uploadedFile.write(tmpFilePath);
		cropImage = true;
		editing = false;
		editingSku = false;
	} catch (Exception e) {
		// logger.error("Erro ao salvar a imagem", e);
		addMessage("admin.produtos.erro_upload", FacesMessage.SEVERITY_ERROR);
	}
}
 
开发者ID:raphaelazzolini,项目名称:mercurius,代码行数:22,代码来源:ProductsAdminMBean.java

示例2: UploadedFileIterator

import org.primefaces.model.UploadedFile; //导入方法依赖的package包/类
public UploadedFileIterator(UploadedFile item, String... extension) throws IOException {
    super();
    this.extension = extension;
    isZip = item.getFileName().toLowerCase().endsWith(".zip");
    itemInputStream = item.getInputstream();
    if (isZip) {
        try {
            in = new MyInputStream(
                    new ArchiveStreamFactory().createArchiveInputStream("zip", itemInputStream));
            // moveNext();
        } catch (ArchiveException e) {
            throw new IOException(e);
        }
    } else if (isValid(item.getFileName())) {
        next = new FileInputStreamWrapper(item.getFileName(), itemInputStream);
    }
}
 
开发者ID:intuit,项目名称:Tank,代码行数:18,代码来源:UploadedFileIterator.java

示例3: upload

import org.primefaces.model.UploadedFile; //导入方法依赖的package包/类
public void upload(FileUploadEvent event) {
    final UploadedFile file = event.getFile();
    if (file == null) return;

    FacesMessage message;
    try {
        linksInspector.from(file.getInputstream());

        message = new FacesMessage("Leídas con éxito " + linksInspector.getLinks().size() + " URLs del fichero: " + file.getFileName(), "");

    } catch (IOException e) {
        message = new FacesMessage(SEVERITY_ERROR, "No se puede leer el fichero: " + file.getFileName(), e.getLocalizedMessage());
        e.printStackTrace();
    }

    FacesContext.getCurrentInstance().addMessage(null, message);
}
 
开发者ID:autentia,项目名称:urmiche,代码行数:18,代码来源:InspectUrlsView.java

示例4: save

import org.primefaces.model.UploadedFile; //导入方法依赖的package包/类
/**
 * Saves the script in the database.
 */
public String save() {
    UploadedFile item = getFile();
    try {
        String fileName = item.getFileName();
        fileName = FilenameUtils.getBaseName(fileName) + "-" + UUID.randomUUID().toString() + "."
                + FilenameUtils.getExtension(fileName);
        File parent = new File("uploads");
        parent.mkdirs();
        File f = new File(parent, fileName);
        LOG.info("Writing file to " + f.getAbsolutePath());
        FileUtils.writeByteArrayToFile(f, item.getContents());
        messages.info("Wrote file to " + f.getAbsolutePath());
    } catch (Exception e) {
        messages.error(e.getMessage());
    }
    return null;
}
 
开发者ID:intuit,项目名称:Tank,代码行数:21,代码来源:TestUploadBean.java

示例5: handleFileUpload

import org.primefaces.model.UploadedFile; //导入方法依赖的package包/类
public void handleFileUpload(FileUploadEvent event) {
	UploadedFile uploadedFile = event.getFile();
	bucketObject.setContentType(uploadedFile.getContentType());
	bucketObject.setSize(uploadedFile.getSize());
	
	if (contentDispositionFilename == null || contentDispositionFilename.isEmpty()) {
		this.contentDispositionFilename = uploadedFile.getFileName();
	}
	
	try (InputStream is = event.getFile().getInputstream()) {
		Path tempFile = Files.createTempFile(null, null);
		Files.copy(is, tempFile, StandardCopyOption.REPLACE_EXISTING);
		this.content = new LazyFileInputStream(tempFile);
	} catch (IOException ex) {
		LOG.log(Level.SEVERE, "Could not locally save the file!", ex);
	}
}
 
开发者ID:Blazebit,项目名称:blaze-storage,代码行数:18,代码来源:BucketObjectAddPage.java

示例6: uploadFile

import org.primefaces.model.UploadedFile; //导入方法依赖的package包/类
public void uploadFile( FileUploadEvent event ) {
	try {
		UploadedFile file = event.getFile();
		InputStream is = file.getInputstream();
		OutputStream os = new FileOutputStream(new File(getTmpDir(), file.getFileName()));
		IOUtils.copy(is, os);
		is.close();
		os.close();
		files.add(file.getFileName());
		if( isUsingMsf() )
			getCfg().setPsmScore(ScoreType.SEQUEST_XCORR);
	} catch( Exception e ) {			
	}
}
 
开发者ID:akrogp,项目名称:EhuBio,代码行数:15,代码来源:ExperimentMB.java

示例7: uploadFasta

import org.primefaces.model.UploadedFile; //导入方法依赖的package包/类
public void uploadFasta( FileUploadEvent event ) {
	try {
		UploadedFile file = event.getFile();
		InputStream is = file.getInputstream();
		OutputStream os = new FileOutputStream(new File(getFastaDir(), file.getFileName()));
		IOUtils.copy(is, os);
		is.close();
		os.close();
	} catch( Exception e ) {			
	}
}
 
开发者ID:akrogp,项目名称:EhuBio,代码行数:12,代码来源:DatabaseMB.java

示例8: cadastrarGif

import org.primefaces.model.UploadedFile; //导入方法依赖的package包/类
public void cadastrarGif() {
	
	if(validarDados()){
		NetgifxCommand command = new NetgifxCommand();
		UploadedFile arq = arquivo;
		try {
			
			FacesContext.getCurrentInstance().getResourceLibraryContracts();
			
			InputStream in = new BufferedInputStream(arq.getInputstream());
			
			String realPath = FacesContext.getCurrentInstance().getExternalContext().getRealPath("/resources/static/img");
			
			File file = new File(realPath, arq.getFileName());
			
			gif.setCaminho("static/img/" + file.getName().replace(".gif", ""));
			gif.setDataPublicacao(LocalDate.now());
			
			
			ArquivoUtil.gravarArquivo(in, file);
			ConversorImagensUtil.converterGifParaPng(file);
			command.cadastrarGif(gif);
			
			
			gif = new Gif();
			arquivo = null;
			categoriasSelecionadas = null;
			
			FacesContext.getCurrentInstance().addMessage(
	                 null, new FacesMessage(FacesMessage.SEVERITY_INFO,
	                 "GIF cadastrado com sucesso!", "GIF cadastrado com sucesso!"));
			
		} catch (Exception ex) {
			FacesContext.getCurrentInstance().addMessage(
	                 null, new FacesMessage(FacesMessage.SEVERITY_ERROR,
	                 "Ocorreu um erro ao tentar cadastrar o gif!", "Ocorreu um erro ao tentar cadastrar o gif!"));
		}
	}
}
 
开发者ID:pedrohnog,项目名称:Trabalhos-FIAP,代码行数:40,代码来源:CadastroGifMB.java

示例9: upload

import org.primefaces.model.UploadedFile; //导入方法依赖的package包/类
public String upload(UploadedFile file,String path) throws IOException{
   	try (InputStream input = file.getInputstream()) {
           Date date = new Date();
           long datetime = date.getTime();
           Files.copy(input, new File(path + file.getFileName()).toPath());
           File fileper = new File(path + file.getFileName());
   	    fileper.setReadable(true, false);
   	    fileper.setWritable(true, false);
   	    //setSshkeypath("/Users/darrenw/dicegui/DICEFITGUI/Uploads/"+ datetime + file.getFileName());
    	 String SSHKeyPath = path + datetime + file.getFileName();

   	   return SSHKeyPath;
   	}     
}
 
开发者ID:dice-project,项目名称:DICE-Fault-Injection-GUI,代码行数:15,代码来源:Uploader.java

示例10: handleImageFileUpload

import org.primefaces.model.UploadedFile; //导入方法依赖的package包/类
/**
 * Copy uploaded file to temp area, until we are ready to save
 * Copy filename into Dataverse logo 
 * @param event 
 */

public void handleImageFileUpload(FileUploadEvent event) {

        logger.finer("entering fileUpload");
        if (this.tempDir==null) {
            createTempDir();
            logger.finer("created tempDir");
        }
        UploadedFile uFile = event.getFile();
    try {         
        uploadedFile = new File(tempDir, uFile.getFileName());     
        if (!uploadedFile.exists()) {
            uploadedFile.createNewFile();
        }
        logger.finer("created file");
        Files.copy(uFile.getInputstream(), uploadedFile.toPath(),StandardCopyOption.REPLACE_EXISTING);
        logger.finer("copied inputstream to file");
        editDv.getDataverseTheme().setLogo(uFile.getFileName());

    } catch (IOException e) {
        logger.finer("caught IOException");
        logger.throwing("ThemeWidgetFragment", "handleImageFileUpload", e);
        throw new RuntimeException("Error uploading logo file", e); // improve error handling
    }
    // If needed, set the default values for the logo
    if (editDv.getDataverseTheme().getLogoFormat()==null) {
        editDv.getDataverseTheme().setLogoFormat(DataverseTheme.ImageFormat.SQUARE);
    }
    logger.finer("end handelImageFileUpload");
}
 
开发者ID:pengchengluo,项目名称:Peking-University-Open-Research-Data-Platform,代码行数:36,代码来源:ThemeWidgetFragment.java


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