0
그래서 저는 아래에 okhttp를 사용하는 개조 2로 작업하고 있습니다. 아래의 코드 조각은 작동하지만 큰 파일의 경우 OOM 오류가 발생합니다. 바이트 배열로 파일을 읽고 있기 때문에 이것이라고 생각합니다.개조 된 대형 Base64 인코딩 파일을 업로드하는 올바른 방법은 무엇입니까?
이 작업을 수행하는 가장 좋은 방법은 무엇입니까?
private void appendFileContentsToBody(Attachment attachment, MultipartBody.Builder requestBodyBuilder) throws IOException {
File file = new File(attachment.getAbsolutePath());
if(file.exists()){
RequestBody attachmentPart = RequestBody.create(null, Base64.getEncoder().encode(FileUtils.readFileToByteArray(file)));
requestBodyBuilder.addPart(Headers.of("X-Filename", attachment.getFilename()), attachmentPart);
}
}