本文整理汇总了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() );
}
示例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 );
}
}
示例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 );
}
}