Some optimiziations for file upload code.
parent
e369258c30
commit
100f6f45f8
|
|
@ -32,6 +32,7 @@ import org.librecms.contentsection.AssetRepository;
|
||||||
import org.librecms.ui.contentsections.AssetPermissionsChecker;
|
import org.librecms.ui.contentsections.AssetPermissionsChecker;
|
||||||
import org.librecms.ui.contentsections.ContentSectionNotFoundException;
|
import org.librecms.ui.contentsections.ContentSectionNotFoundException;
|
||||||
|
|
||||||
|
import java.io.BufferedInputStream;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
@ -378,32 +379,28 @@ public class FileAssetEditStep extends AbstractMvcAssetEditStep {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// try ( InputStream fileInputStream = Files.newInputStream(
|
final Blob data = BlobProxy.generateProxy(
|
||||||
// tmpFilePath
|
Files.newInputStream(tmpFilePath), -1
|
||||||
// )) {
|
);
|
||||||
|
fileAsset.setFileName(fileName);
|
||||||
final Blob data = BlobProxy.generateProxy(
|
fileAsset.setData(data);
|
||||||
Files.newInputStream(tmpFilePath), -1
|
|
||||||
);
|
|
||||||
fileAsset.setFileName(fileName);
|
|
||||||
fileAsset.setData(data);
|
|
||||||
|
|
||||||
fileAsset.setSize(fileSize);
|
fileAsset.setSize(fileSize);
|
||||||
// fileAsset.setSize(fileAsset.getData().length);
|
// fileAsset.setSize(fileAsset.getData().length);
|
||||||
try {
|
try {
|
||||||
fileAsset.setMimeType(new MimeType(contentType));
|
fileAsset.setMimeType(new MimeType(contentType));
|
||||||
} catch (MimeTypeParseException ex) {
|
} catch (MimeTypeParseException ex) {
|
||||||
LOGGER.error(
|
LOGGER.error(
|
||||||
"Failed to upload file for FileAsset {}:",
|
"Failed to upload file for FileAsset {}:",
|
||||||
assetPath
|
assetPath
|
||||||
);
|
);
|
||||||
LOGGER.error(ex);
|
LOGGER.error(ex);
|
||||||
|
|
||||||
models.put("uploadFailed", true);
|
models.put("uploadFailed", true);
|
||||||
return buildRedirectPathForStep();
|
return buildRedirectPathForStep();
|
||||||
}
|
}
|
||||||
|
|
||||||
assetRepo.save(fileAsset);
|
assetRepo.save(fileAsset);
|
||||||
// }
|
// }
|
||||||
// try ( InputStream inputStream = inputPart.getBody(
|
// try ( InputStream inputStream = inputPart.getBody(
|
||||||
// InputStream.class, null)) {
|
// InputStream.class, null)) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue