0
public void drop(DragAndDropEvent dropEvent) {
WrapperTransferable tr = (WrapperTransferable) dropEvent.getTransferable();
Html5File[] files = tr.getFiles();
if (files != null) {
for (final Html5File html5File : files) {
final String fileName = html5File.getFileName();
final ByteArrayOutputStream bas = new ByteArrayOutputStream();
StreamVariable streamVariable = new StreamVariable() {
public OutputStream getOutputStream() {
return bas;
}
public boolean listenProgress() {
return false;
}
public void onProgress(StreamingProgressEvent event) {
}
public void streamingStarted(
StreamingStartEvent event) {
}
public void streamingFinished(
StreamingEndEvent event) {
progress.setVisible(false);
showFile(fileName, html5File.getType(), bas);
}
public void streamingFailed(
StreamingErrorEvent event) {
progress.setVisible(false);
}
public boolean isInterrupted() {
return false;
}
};
html5File.setStreamVariable(streamVariable);
progress.setVisible(true);
encryptAndUploadFile(***html5File****, fileName, folderName);
//我怎麼能這樣html5File轉換成java.io.File,因爲我有一個接受文件參數如何在vaadin中將Html5File轉換爲java.io.File?
}
}
}
// encryptAndUploadFile()方法
public void encryptAndUploadFile(File file, String fileName,String folderName)
{
String m_strWebFilePath = finalSourcepath + fileName;
File m_objFile=null;
byte[] sourceFileByte = Encryption.aesEncrypt(com.saterisystems.common.utils.FileUtils.getImageIntoByteArray(file), GlobalConstants.KEY.getBytes(), GlobalConstants.IV.getBytes());
......
......
......
請一個encryptAndUploadFile方法建議我如何將此Html5File類型對象轉換爲java.io.File類型對象?
html5File.getFileName()僅給出文件名不是整個文件路徑。所以雖然這個陳述** File file = new File(html5File.getFileName())**拋出異常。 –
Html5File僅支持(Name,FileSize,Type) –