use of com.valdir.jornadaback.services.exceptions.FileException in project jornada-back by ValdirCezar.
the class S3ServiceImpl method uploadFile.
@Override
public URI uploadFile(String fileName, InputStream inputStream, String contentType, Long classId) {
try {
var metadata = new ObjectMetadata();
metadata.setContentType(contentType);
s3Client.putObject(bucketName + "/classes/classId-" + classId, fileName, inputStream, metadata);
return s3Client.getUrl(bucketName, fileName).toURI();
} catch (URISyntaxException e) {
throw new FileException("Erro ao converter URL para URI");
}
}
use of com.valdir.jornadaback.services.exceptions.FileException in project jornada-back by ValdirCezar.
the class S3ServiceImpl method uploadFile.
@Override
public URI uploadFile(MultipartFile file, Long classId) {
try {
String fileName = file.getOriginalFilename();
verifyExtension(fileName);
InputStream inputStream = file.getInputStream();
String contentType = file.getContentType();
return uploadFile(fileName, inputStream, contentType, classId);
} catch (IOException e) {
throw new FileException("Erro de IO" + e.getMessage());
}
}
Aggregations