use of io.vertigo.dynamo.file.model.VFile in project vertigo by KleeGroup.
the class TestUtil method createVFile.
/**
* Crée un VFile relativement d'un class de base.
* @param fileName Nom/path du fichier
* @param baseClass Class de base pour le chemin relatif
* @return VFile
*/
public static VFile createVFile(final FileManager fileManager, final String fileName, final Class<?> baseClass) {
try {
try (final InputStream in = baseClass.getResourceAsStream(fileName)) {
Assertion.checkNotNull(in, "fichier non trouvé : {0}", fileName);
final File file = new TempFile("tmp", '.' + FileUtil.getFileExtension(fileName));
FileUtil.copy(in, file);
return fileManager.createFile(file);
}
} catch (final IOException e) {
throw WrappedException.wrap(e);
}
}
use of io.vertigo.dynamo.file.model.VFile in project vertigo by KleeGroup.
the class TextIdentityProviderPlugin method getPhoto.
/**
* {@inheritDoc}
*/
@Override
public <E extends Entity> Optional<VFile> getPhoto(final URI<E> accountURI) {
final IdentityUserInfo identityAccountInfo = users.get(accountURI.getId());
Assertion.checkNotNull(identityAccountInfo, "No account found for {0}", accountURI);
if (identityAccountInfo.getPhotoUrl() == null) {
return Optional.empty();
}
final File photoFile = new File(identityAccountInfo.getPhotoUrl());
if (!photoFile.exists()) {
return Optional.empty();
}
try {
final String contentType = Files.probeContentType(photoFile.toPath());
return Optional.of(new FSFile("photoOf" + accountURI.getId(), contentType, photoFile));
} catch (final IOException e) {
throw WrappedException.wrap(e);
}
}
use of io.vertigo.dynamo.file.model.VFile in project vertigo by KleeGroup.
the class FileDownloadWebServices method testDownloadFile.
@AnonymousAccessAllowed
@GET("/downloadFileContentType")
public VFile testDownloadFile(@QueryParam("id") final Integer id) {
final URL imageUrl = resourcetManager.resolve("npi2loup.png");
final File imageFile = asFile(imageUrl);
return fileManager.createFile("image" + id + generateSpecialChars(id) + ".png", "image/png", imageFile);
}
use of io.vertigo.dynamo.file.model.VFile in project vertigo by KleeGroup.
the class AdvancedTestWebServices method testExportContact.
@GET("/export/pdf/{conId}")
public VFile testExportContact(@PathParam("conId") final long conId) throws URISyntaxException {
final URL tempFile = resourcetManager.resolve("io/vertigo/vega/webservice/data/ws/contact2.pdf");
final VFile result = fileManager.createFile(new File(tempFile.toURI()));
// 200
return result;
}
use of io.vertigo.dynamo.file.model.VFile in project vertigo by KleeGroup.
the class AdvancedTestWebServices method testDownloadFile.
@GET("/downloadFile")
public VFile testDownloadFile(@QueryParam("id") final Integer id) {
final URL imageUrl = resourcetManager.resolve("npi2loup.png");
final File imageFile = asFile(imageUrl);
final VFile imageVFile = fileManager.createFile("image" + id + ".png", "image/png", imageFile);
return imageVFile;
}
Aggregations