private FileMeta createFileMeta(String jobExecutionID, File file) { FileMeta fileMeta = fileMetaFactory.create(jobExecutionID); fileMeta.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); fileMeta.setSize(file.length()); fileMeta.setFilename(jobExecutionID + '/' + file.getName()); fileMeta.setUrl("/files/" + jobExecutionID); return fileMeta; } }
} else { File fileStoreFile = fileStore.getFile(fileMeta.getFilename()); if (!fileStoreFile.exists()) { fileStoreFile = fileStore.getFile(id); String outputFilename = fileMeta.getFilename(); String contentType = fileMeta.getContentType(); if (contentType != null) { response.setContentType(contentType); Long size = fileMeta.getSize(); if (size != null) { response.setContentLength(size.intValue());
private void validateResourceZip(App app) { FileMeta appZipMeta = app.getSourceFiles(); if (appZipMeta != null) { File fileStoreFile = fileStore.getFile(appZipMeta.getId()); if (fileStoreFile == null) { LOG.error("Resource zip '{}' for app '{}' missing in file store", appZipMeta.getId(), app.getName()); throw new RuntimeException("An error occurred trying to create or update app"); } ZipFile zipFile; try { zipFile = new ZipFile(fileStoreFile); } catch (ZipException e) { LOG.error("Error creating zip file object", e); throw new RuntimeException("An error occurred trying to create or update app"); } if (!zipFile.isValidZipFile()) { throw new MolgenisValidationException(new ConstraintViolation( String.format("'%s' is not a valid zip file.", appZipMeta.getFilename()))); } } } }
if (appSourceArchive != null) File fileStoreFile = fileStore.getFile(appSourceArchive.getId()); if (fileStoreFile == null) LOG.error("Source archive '{}' for app '{}' missing in file store", appSourceArchive.getId(), app.getName()); throw new RuntimeException("An error occurred trying to activate app");
@Override @RunAsSystem public FileSystemResource getThemeData(String styleName, BootstrapVersion bootstrapVersion) throws MolgenisStyleException { StyleSheet styleSheet = findThemeByName(styleName); if (styleSheet == null) { throw new MolgenisStyleException("No theme found for with name: " + styleName); } // Fetch the theme file from the store. FileMeta fileMeta; if (bootstrapVersion.equals(BOOTSTRAP_VERSION_3)) { fileMeta = styleSheet.getBootstrap3Theme(); } else { fileMeta = styleSheet.getBootstrap4Theme(); // If no bootstrap 4 theme was set fetch the default theme from the resources folder if (fileMeta == null) { StyleSheet fallBackTheme = findThemeByName(BOOTSTRAP_FALL_BACK_THEME); fileMeta = fallBackTheme.getBootstrap4Theme(); } } File file = fileStore.getFile(fileMeta.getId()); return new FileSystemResource(file); }
private FileMeta createFileMeta(String jobExecutionID, File file) { FileMeta fileMeta = fileMetaFactory.create(jobExecutionID); fileMeta.setContentType("text/csv"); fileMeta.setSize(file.length()); fileMeta.setFilename(jobExecutionID + '/' + file.getName()); fileMeta.setUrl(FileDownloadController.URI + '/' + jobExecutionID); return fileMeta; } }
private FileMeta createFileMeta(File file) { FileMeta fileMeta = fileMetaFactory.create(file.getName()); fileMeta.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); fileMeta.setSize(file.length()); fileMeta.setFilename(file.getName()); fileMeta.setUrl(URI + "/" + file.getName()); return fileMeta; } }
private FileMeta createStyleSheetFileMeta(String fileName, InputStream data) throws MolgenisStyleException { String fileId = idGenerator.generateId(); try { fileStore.store(data, fileId); } catch (IOException e) { throw new MolgenisStyleException("Unable to save style file with name : " + fileName, e); } FileMeta fileMeta = fileMetaFactory.create(fileId); fileMeta.setContentType("css"); fileMeta.setFilename(fileName); fileMeta.setSize(fileStore.getFile(fileId).length()); fileMeta.setUrl(buildFileUrl(fileId)); dataService.add(FileMetaMetaData.FILE_META, fileMeta); return fileMeta; }
if (entity.get(FILENAME).equals(paramValue)) { value = entity; } else { fileEntity.setFilename(multipartFile.getOriginalFilename()); fileEntity.setContentType(multipartFile.getContentType()); fileEntity.setSize(multipartFile.getSize()); ServletUriComponentsBuilder currentRequest = servletUriComponentsBuilderFactory.fromCurrentRequest(); .replaceQuery(null) .build(); fileEntity.setUrl(downloadUri.toUriString()); dataService.add(FILE_META, fileEntity);