В протоколе WOPI возникает ошибка MalformedInputException: длина ввода = 1 при редактировании файлаJAVA

Программисты JAVA общаются здесь
Ответить Пред. темаСлед. тема
Anonymous
 В протоколе WOPI возникает ошибка MalformedInputException: длина ввода = 1 при редактировании файла

Сообщение Anonymous »

Это ошибка при редактировании файла docx с помощью WOPI
[DEBUG][12 Oct 2024 17:38:34,010] () [o.s.c.e.PropertySourcesPropertyResolver] Found key 'FWS_SAVED_FILE_DETAILS_get' in PropertySource 'class path resource [mysql.properties]' with value of type String[DEBUG][12 Oct 2024 17:38:34,011] () [o.s.o.j.JpaTransactionManager] Initiating transaction commit[DEBUG][12 Oct 2024 17:38:34,012] () [o.s.o.j.JpaTransactionManager] Committing JPA transaction on EntityManager [SessionImpl(685169114)][DEBUG][12 Oct 2024 17:38:34,012] () [o.s.o.j.JpaTransactionManager] Not closing pre-bound JPA EntityManager after transaction[DEBUG][12 Oct 2024 17:38:34,012] () [c.b.w.s.WOPIService] putFile()-fwsSavedFileDetails=com.beyondsquare.interfaces.filewriter.entity.FWS_SAVED_FILE_DETAILS@2c40d420[DEBUG][12 Oct 2024 17:38:34,012] () [c.b.w.s.WOPIService] Content-Type...............................: null[DEBUG][12 Oct 2024 17:38:34,037] () [o.s.w.s.DispatcherServlet] Failed to complete request: java.nio.charset.MalformedInputException: Input length = 1[DEBUG][12 Oct 2024 17:38:34,038] () [o.s.o.j.s.OpenEntityManagerInViewFilter] Closing JPA EntityManager in OpenEntityManagerInViewFilter[ERROR][12 Oct 2024 17:38:34,038] () [c.b.ExpiredSessionFilter] callChain()-Error in filter chaining::Input length = 1[ERROR][12 Oct 2024 17:38:34,039] () [c.b.ExpiredSessionFilter] callChain()-Nested exception is::

Это мой код для метода putfile. получаю ошибку в блоке try-catch
public void putFile(Integer fileId, HttpServletRequest request) throws IOException {
LOGGER.debug("putFile()-request.getCharacterEncoding()={}", request.getCharacterEncoding());
// Retrieve file details using the provided fileId
LOGGER.debug("putFile()-file_id={}", fileId);
FWS_SAVED_FILE_DETAILS fwsSavedFileDetails = fwsSavedFileDetailsService.getById(fileId);
LOGGER.debug("putFile()-fwsSavedFileDetails={}", fwsSavedFileDetails);
String contentType = request.getContentType();
LOGGER.debug("Content-Type.......................: {}", contentType);
// Get headers for lock management
String requestLock = request.getHeader("X-WOPI-Lock");

// Handle lock validation if needed (commented out for now)
/*
if (requestLock != null && requestLock.equals("IncorrectLockString")) {
response.setHeader("X-WOPI-Lock", fileData.getLockValue());
return Response.status(Response.Status.CONFLICT).build();
}
*/

File outputFile = File.createTempFile(fwsSavedFileDetails.getFileName(), ".tmp");
LOGGER.debug("putFile()-outputFile={}", outputFile.getAbsolutePath());

try (InputStream inputStream = request.getInputStream();
InputStreamReader reader = new InputStreamReader(inputStream, "UTF-8"); // Use UTF-8
FileOutputStream fos = new FileOutputStream(outputFile)) {

// Read the entire input stream into a byte array
byte[] fileContent = inputStream.readAllBytes(); // Java 9+ method
LOGGER.debug("putFile()-fileContent={} length={}", fileContent, fileContent.length);

// Write the byte array to the output file
fos.write(fileContent);
} catch (IOException ex) {
LOGGER.error("putFile()-Error occurred::{}", ex.getMessage(), ex);
throw new RuntimeException("Error writing file: " + ex.getMessage(), ex);
}

// Prepare the UploadFileVO object with necessary details
UploadFileVO uploadFileVO = new UploadFileVO();
uploadFileVO.setInputStream(new FileInputStream(outputFile));
LOGGER.debug("putFile()-inputstream={}", uploadFileVO.getInputStream().available());
uploadFileVO.setContentLength(outputFile.length()); // Use the length of the output file
LOGGER.debug("putFile()-contentLength={}", uploadFileVO.getContentLength());
uploadFileVO.setFileName(fwsSavedFileDetails.getFileName());
uploadFileVO.setArchiveLocation(fwsSavedFileDetails.getFile_path());
uploadFileVO.setFinalyzerHostname(BSMethod.getHostname(request, userContextAndTokenExpiringCacheService));
LOGGER.debug("putFile()-finalyzerHostname={}", uploadFileVO.getFinalyzerHostname());
uploadFileVO.setUserName(fwsSavedFileDetails.getCreated_by());
LOGGER.debug("putFile()-userName={}", uploadFileVO.getUserName());
uploadFileVO.setTenantId(fwsSavedFileDetails.getTenant_id());
uploadFileVO.setTempDirectory((File) request.getServletContext().getAttribute("javax.servlet.context.tempdir"));
LOGGER.debug("putFile()-tempDirectory={}", uploadFileVO.getTempDirectory());

// Call the service to write the file
fws.writeFileInBytes(fwsSavedFileDetails.getApplication_connection_id(), uploadFileVO);
LOGGER.debug("putFile()-write file from WOPI call success={}", fwsSavedFileDetails.getFileName());
}


Подробнее здесь: https://stackoverflow.com/questions/790 ... -1-on-edit
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «JAVA»