アプリケーションを作成していて、顧客のイメージ写真があります。この画像を取得して ftp にアップロードするにはどうすればよいですか?
アップロードの章でvaadin7の本を読んで、例を作成しましたが機能しませんでした。このイメージ画像をftpにも送信する方法を探しています。
私はこれを試しました。
/** My UI */
//foto
Image picture = new Image();
picture.setWidth("128px");
picture.setHeight("128px");
mainLayout.addComponent(foto);
//upload image picture
ImageUpload imageUp = new ImageUpload(picture);
Upload upload = new Upload();
upload.setCaption("Find your picture");
upload.setButtonCaption("Send");
upload.addSucceededListener(imageUp);
mainLayout.addComponent(upload);
/** class upload image picture */
public class ImageUpload implements Receiver, SucceededListener{
private File file;
private Image image;
public ImageUpload(Image image){
this.image = image;
this.image.setVisible(false);
}
@Override
public void uploadSucceeded(SucceededEvent event) {
this.image.setVisible(true);
this.image.setSource(new FileResource(file));
}
@Override
public OutputStream receiveUpload(String filename, String mimeType) {
FileOutputStream fos = null;
try{
file = new File("/tmp/" + filename);
fos = new FileOutputStream(file);
}catch(final java.io.FileNotFoundException ex){
new Notification("File not found \n",
ex.getLocalizedMessage(),
Notification.Type.ERROR_MESSAGE)
.show(Page.getCurrent());
}
return fos;
}
}
何か案が ?
ありがとう