List of usage examples for com.liferay.portal.util PropsValues STAGING_REMOTE_TRANSFER_BUFFER_SIZE
int STAGING_REMOTE_TRANSFER_BUFFER_SIZE
To view the source code for com.liferay.portal.util PropsValues STAGING_REMOTE_TRANSFER_BUFFER_SIZE.
Click Source Link
From source file:com.liferay.exportimport.internal.background.task.LayoutRemoteStagingBackgroundTaskExecutor.java
License:Open Source License
protected void transferFileToRemoteLive(File file, long stagingRequestId, HttpPrincipal httpPrincipal) throws Exception { byte[] bytes = new byte[PropsValues.STAGING_REMOTE_TRANSFER_BUFFER_SIZE]; int i = 0;//from ww w . j av a 2 s .c o m int j = 0; String numberString = String.valueOf((int) (file.length() / bytes.length)); String numberFormat = String.format("%%0%dd", numberString.length() + 1); try (FileInputStream fileInputStream = new FileInputStream(file)) { while ((i = fileInputStream.read(bytes)) >= 0) { String fileName = file.getName() + String.format(numberFormat, j++); if (i < PropsValues.STAGING_REMOTE_TRANSFER_BUFFER_SIZE) { byte[] tempBytes = new byte[i]; System.arraycopy(bytes, 0, tempBytes, 0, i); StagingServiceHttp.updateStagingRequest(httpPrincipal, stagingRequestId, fileName, tempBytes); } else { StagingServiceHttp.updateStagingRequest(httpPrincipal, stagingRequestId, fileName, bytes); } bytes = new byte[PropsValues.STAGING_REMOTE_TRANSFER_BUFFER_SIZE]; } } }