바이너리 파일 리소스를 수신 할 수있는 REST 서비스를 작성하고 있습니다.http로 브라우저에서 바이너리로 보낸 base64 인코딩 된 데이터 저장
RESTEXPRESS를 사용 중이며 HTTP를 통해 인코딩 된 base64 문자열로 이진 데이터를 보냅니다.
파일을 첨부 파일로받을 수 있지만 브라우저가 base64를 바이너리로 다시 디코딩하지 못하게하는 헤더 조합이 있습니다.
내 목표가 가능합니까? http를 통해 임의의 바이너리 fileformat을 보내고 브라우저가 base64에서 바이너리로 자동으로 디코딩하여 파일을 저장하게하십시오. 또는 브라우저가 파일 확장명과 연결된 응용 프로그램을 트리거하도록 하시겠습니까? 이 작업을 투명하게 처리 할 수 있습니까? 아니면 자바 스크립트를 사용해야합니까?
내가 사용하는 헤더를 보여주는 코드는 다음과 같습니다.
public String read(Request request, Response response) throws IOException
{
response.setIsSerialized(false);
response.setContentType("application/arbitraryBinaryFileFormat");
response.addHeader("Content-Transfer-Encoding", "Base64");
response.addHeader("Content-Encoding", "Base64");
response.addHeader("Content-Disposition","attachment; filename=r.arbitraryBinaryFileFormat");
String result = encodeFileToBase64Binary("/Users/xxx/Downloads/r.arbitraryBinaryFileFormat");
response.setBody(result);
return result;
}