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


Java MultipartBody.getAttachment方法代码示例

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


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

示例1: getStringValue

import org.apache.cxf.jaxrs.ext.multipart.MultipartBody; //导入方法依赖的package包/类
private String getStringValue( MultipartBody multipartBody, String attachmentId )
    throws IOException
{
    Attachment attachment = multipartBody.getAttachment( attachmentId );
    return attachment == null ? "" : IOUtils.toString( attachment.getDataHandler().getInputStream() );
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:7,代码来源:DefaultFileUploadService.java

示例2: post

import org.apache.cxf.jaxrs.ext.multipart.MultipartBody; //导入方法依赖的package包/类
@Override
public FileMetadata post( MultipartBody multipartBody )
    throws ArchivaRestServiceException
{

    try
    {

        String classifier = getStringValue( multipartBody, "classifier" );
        String packaging = getStringValue( multipartBody, "packaging" );
        // skygo: http header form pomFile was once sending 1 for true and void for false
        // leading to permanent false value for pomFile if using toBoolean(); use , "1", ""
        boolean pomFile = BooleanUtils.toBoolean( getStringValue( multipartBody, "pomFile" ) );

        Attachment file = multipartBody.getAttachment( "files[]" );

        //Content-Disposition: form-data; name="files[]"; filename="org.apache.karaf.features.command-2.2.2.jar"
        String fileName = file.getContentDisposition().getParameter( "filename" );

        File tmpFile = File.createTempFile( "upload-artifact", ".tmp" );
        tmpFile.deleteOnExit();
        IOUtils.copy( file.getDataHandler().getInputStream(), new FileOutputStream( tmpFile ) );
        FileMetadata fileMetadata = new FileMetadata( fileName, tmpFile.length(), "theurl" );
        fileMetadata.setServerFileName( tmpFile.getPath() );
        fileMetadata.setClassifier( classifier );
        fileMetadata.setDeleteUrl( tmpFile.getName() );
        fileMetadata.setPomFile( pomFile );
        fileMetadata.setPackaging( packaging );

        log.info( "uploading file: {}", fileMetadata );

        List<FileMetadata> fileMetadatas = getSessionFilesList();

        fileMetadatas.add( fileMetadata );

        return fileMetadata;
    }
    catch ( IOException e )
    {
        throw new ArchivaRestServiceException( e.getMessage(),
                                               Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), e );
    }

}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:45,代码来源:DefaultFileUploadService.java

示例3: post

import org.apache.cxf.jaxrs.ext.multipart.MultipartBody; //导入方法依赖的package包/类
@Override
public FileMetadata post( MultipartBody multipartBody )
    throws ArchivaRestServiceException
{

    try
    {

        String classifier = getStringValue( multipartBody, "classifier" );
        String packaging = getStringValue( multipartBody, "packaging" );
        // skygo: http header form pomFile was once sending 1 for true and void for false
        // leading to permanent false value for pomFile if using toBoolean(); use , "1", ""
        boolean pomFile = BooleanUtils.toBoolean( getStringValue( multipartBody, "pomFile" ) );

        Attachment file = multipartBody.getAttachment( "files[]" );

        //Content-Disposition: form-data; name="files[]"; filename="org.apache.karaf.features.command-2.2.2.jar"
        String fileName = file.getContentDisposition().getParameter( "filename" );

        Path tmpFile = Files.createTempFile( "upload-artifact", ".tmp" );
        tmpFile.toFile().deleteOnExit();
        IOUtils.copy( file.getDataHandler().getInputStream(), new FileOutputStream( tmpFile.toFile() ) );
        FileMetadata fileMetadata = new FileMetadata( fileName, Files.size(tmpFile), "theurl" );
        fileMetadata.setServerFileName( tmpFile.toString() );
        fileMetadata.setClassifier( classifier );
        fileMetadata.setDeleteUrl( tmpFile.getFileName().toString() );
        fileMetadata.setPomFile( pomFile );
        fileMetadata.setPackaging( packaging );

        log.info( "uploading file: {}", fileMetadata );

        List<FileMetadata> fileMetadatas = getSessionFilesList();

        fileMetadatas.add( fileMetadata );

        return fileMetadata;
    }
    catch ( IOException e )
    {
        throw new ArchivaRestServiceException( e.getMessage(),
                                               Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), e );
    }

}
 
开发者ID:apache,项目名称:archiva,代码行数:45,代码来源:DefaultFileUploadService.java


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