Image handling and file upload bug fixes.
parent
204c2ee39d
commit
0f44e9d70c
|
|
@ -81,9 +81,10 @@ public class BinaryAssetBlobDataProvider implements BinaryAssetDataProvider {
|
|||
final Blob blob = resultSet.getBlob("asset_data");
|
||||
try ( InputStream inputStream = blob.getBinaryStream()) {
|
||||
byte[] buffer = new byte[8192];
|
||||
int length;
|
||||
while ((length = inputStream.read(buffer)) != -1) {
|
||||
int length = inputStream.read(buffer);
|
||||
while (length != -1) {
|
||||
outputStream.write(buffer, 0, length);
|
||||
length = inputStream.read(buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -109,13 +110,24 @@ public class BinaryAssetBlobDataProvider implements BinaryAssetDataProvider {
|
|||
final Path tmpFilePath = Files.createTempFile("upload", fileName);
|
||||
int fileSize = 0;
|
||||
try ( OutputStream outputStream = Files.newOutputStream(tmpFilePath)) {
|
||||
int length;
|
||||
byte[] buffer = new byte[8192];
|
||||
while ((length = inputStream.read(buffer)) != -1) {
|
||||
outputStream.write(buffer);
|
||||
int length = inputStream.read(buffer);
|
||||
fileSize += length;
|
||||
while(length != -1) {
|
||||
outputStream.write(buffer, 0, length);
|
||||
length = inputStream.read(buffer);
|
||||
fileSize += length;
|
||||
}
|
||||
outputStream.flush();
|
||||
// while ((length = inputStream.read(buffer)) != -1) {
|
||||
// outputStream.write(buffer);
|
||||
// fileSize += length;
|
||||
// }
|
||||
// int dataByte = inputStream.read();
|
||||
// while (dataByte != -1) {
|
||||
// fileSize++;
|
||||
// outputStream.write(dataByte);
|
||||
// dataByte = inputStream.read();
|
||||
// }
|
||||
}
|
||||
|
||||
final Blob data = BlobProxy.generateProxy(
|
||||
|
|
|
|||
|
|
@ -26,6 +26,9 @@ import java.awt.image.BufferedImage;
|
|||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.enterprise.context.Dependent;
|
||||
|
|
@ -126,8 +129,14 @@ public class ImageService {
|
|||
);
|
||||
}
|
||||
|
||||
return outputStream.toByteArray();
|
||||
final byte[] result = outputStream.toByteArray();
|
||||
// try {
|
||||
// Files.delete(tmpFilePath);
|
||||
// } catch (IOException ex) {
|
||||
// LOGGER.warn("Failed to delete temporary file.", ex);
|
||||
// }
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private java.awt.Image scaleImage(
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@
|
|||
</c:if>
|
||||
<c:choose>
|
||||
<c:when test="#{CmsImageEditStepModel.dataAvailable}">
|
||||
<figure>
|
||||
<figure class="mt-3">
|
||||
<img alt="#{CmsAssetsStepsDefaultMessagesBundle['image.editstep.preview.alt']}"
|
||||
src="#{mvc.basePath}/#{ContentSectionModel.sectionName}/assets/#{CmsSelectedAssetModel.assetPath}/@image-edit-download?width=320"
|
||||
width="320" />
|
||||
|
|
|
|||
Loading…
Reference in New Issue