Simple UI: Streaming upload (#2254)
thus not loading whole artifact into memory Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -142,8 +142,7 @@ public class DistributionSetView extends TableView<MgmtDistributionSet, Long> {
|
||||
return Filter.filter(
|
||||
Map.of(
|
||||
"name", name.getOptionalValue(),
|
||||
"type", type.getSelectedItems().stream().map(MgmtDistributionSetType::getKey)
|
||||
.toList(),
|
||||
"type", type.getSelectedItems().stream().map(MgmtDistributionSetType::getKey).toList(),
|
||||
"tag", tag.getSelectedItems()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ import com.vaadin.flow.component.upload.receivers.FileBuffer;
|
||||
import com.vaadin.flow.data.renderer.ComponentRenderer;
|
||||
import com.vaadin.flow.router.PageTitle;
|
||||
import com.vaadin.flow.router.Route;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.PagedList;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.artifact.MgmtArtifact;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModule;
|
||||
@@ -63,6 +64,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
@Route(value = "software_modules", layout = MainLayout.class)
|
||||
@RolesAllowed({ "SOFTWARE_MODULE_READ" })
|
||||
@Uses(Icon.class)
|
||||
@Slf4j
|
||||
public class SoftwareModuleView extends TableView<MgmtSoftwareModule, Long> {
|
||||
|
||||
@Autowired
|
||||
@@ -307,9 +309,11 @@ public class SoftwareModuleView extends TableView<MgmtSoftwareModule, Long> {
|
||||
uploadBtn.setDropAllowed(true);
|
||||
uploadBtn.addSucceededListener(e -> {
|
||||
final MgmtArtifact artifact = hawkbitClient.getSoftwareModuleRestApi()
|
||||
.uploadArtifact(softwareModuleId,
|
||||
new MultipartFileImpl(fileBuffer, e.getContentLength(), e.getMIMEType()), fileBuffer.getFileName(), null, null,
|
||||
null).getBody();
|
||||
.uploadArtifact(
|
||||
softwareModuleId,
|
||||
new MultipartFileImpl(fileBuffer, e.getContentLength(), e.getMIMEType()),
|
||||
fileBuffer.getFileName(), null, null, null)
|
||||
.getBody();
|
||||
artifacts.add(artifact);
|
||||
artifactGrid.refreshGrid(false);
|
||||
});
|
||||
@@ -367,6 +371,7 @@ public class SoftwareModuleView extends TableView<MgmtSoftwareModule, Long> {
|
||||
|
||||
@Override
|
||||
public byte[] getBytes() throws IOException {
|
||||
log.warn("Multipart file getBytes() is called. Whole input stream is loaded into the memory!");
|
||||
try (final InputStream is = getInputStream()) {
|
||||
return is.readAllBytes();
|
||||
}
|
||||
|
||||
@@ -16,8 +16,9 @@ logging.level.org.springframework.boot.actuate.audit.listener.AuditListener=WARN
|
||||
# logging pattern
|
||||
logging.pattern.console=%clr(%d{${logging.pattern.dateformat:yyyy-MM-dd'T'HH:mm:ss.SSSXXX}}){faint} %clr(${logging.pattern.level:%5p}) %clr(${PID:}){magenta} %clr(---){faint} %clr([${spring.application.name}] [%X{tenant}:%X{user}] [%15.15t]){faint} %clr(${logging.pattern.correlation:}){faint}%clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${logging.exception-conversion-word:%wEx}
|
||||
|
||||
### Vaadin start ###`
|
||||
### Vaadin start ###
|
||||
# build with mvn vaadin:build-frontend to enable / disable
|
||||
vaadin.productionMode=true
|
||||
vaadin.frontend.hotdeploy=false
|
||||
logging.level.org.atmosphere=warn
|
||||
spring.mustache.check-template-location=false
|
||||
|
||||
Reference in New Issue
Block a user