【发布时间】:2012-02-02 09:15:22
【问题描述】:
我正在使用 java webservice(在 tomcat 上)。 我有以下处理图片上传的代码:
public String uploadPicture( long xId,
int pictureIndex,
String imageData )
{
File imageFile = new File( new String( "D:\\" + xId + "_" + pictureIndex ) );
try
{
FileOutputStream fos = new FileOutputStream( imageFile );
byte[] encodedImage = Base64.decode( imageData );
fos.write( encodedImage );
fos.close();
return imageFile.getPath();
}
catch( FileNotFoundException e )
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch( Base64DecodingException e )
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch( IOException e )
{
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
我将路径指定为 D:\,因为它位于本地 PC 上。 但我需要将其更新为将要部署的服务器上的路径 - 然后应该将其更改为 ~\picDir?类似的东西?
网络服务网址:http://192.168.0.11:8080/XWebService/services/XWebService 将更新为域而不是 192.168.0.11 获取图像的 URL 应该是什么? (例如,如果图片文件夹是:~\picDir)
【问题讨论】:
标签: java web-services image upload