자바 스크립트를 통해 내 웹 페이지에 그림 파일을 BLOB 유형의 파일로 업로드하고 파일을 저장하는 자바 웹 서버 서버로 전송하려고합니다. 웹 페이지에 사용 된 서버 BLOB 데이터를 읽고 다음과 같이 파일이 쓰기로 나는 그것이 Error interpreting JPEG image file (Not a JPEG file: starts with 0x00 0x00)
말한다 사진을 열려고 할 때 websocker 서버 자바 측자바 스크립트 BLOB 데이터를 읽는 방법 자바 웹 서버에서 웹 소켓을 통해 전송
내 코드는 다음
public void testMethod(final WebMessage message){
ByteBuffer b = null;
try {
b = message.getByteBufferArg(0);
} catch (WebMessageException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}
File file = new File("/user/Desktop/pic.jpg");
try {
file.createNewFile();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
FileOutputStream stream = new FileOutputStream(file.getAbsoluteFile());
stream.write(b.array());
logger.info("done writing file");
stream.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
logger.trace(e.getMessage());
}
}
입니다.
기본적으로 나는 내 websocket 서버로 전송 된이 BLOB 데이터를 읽을 수있는 방법을 알고 싶습니다.이 데이터를 쓸 수있는 파일에 어떻게 쓸 수 있습니까?