use of com.epam.pipeline.entity.datastorage.DataStorageStreamingContent in project cloud-pipeline by epam.
the class S3Helper method getFileStream.
public DataStorageStreamingContent getFileStream(AbstractDataStorage dataStorage, String path, String version) {
try {
AmazonS3 client = getDefaultS3Client();
GetObjectRequest rangeObjectRequest = new GetObjectRequest(dataStorage.getPath(), path, version);
S3Object object = client.getObject(rangeObjectRequest);
return new DataStorageStreamingContent(object.getObjectContent(), object.getKey());
} catch (AmazonS3Exception e) {
if (e.getStatusCode() == NOT_FOUND) {
throw new DataStorageException(String.format("File '%s' doesn't exist", path));
} else {
throw new DataStorageException(e.getMessage(), e);
}
}
}
use of com.epam.pipeline.entity.datastorage.DataStorageStreamingContent in project cloud-pipeline by epam.
the class AttachmentFileManagerTest method testDownloadAttachment.
@Test
public void testDownloadAttachment() {
DataStorageStreamingContent content = attachmentFileManager.downloadAttachment(1L);
Assert.assertNotNull(content.getContent());
Assert.assertEquals(TEST_ATTACHMENT_NAME, content.getName());
verify(dataStorageManager).loadByNameOrId(TEST_SYSTEM_DATA_STORAGE);
verify(attachmentManager).load(1L);
verify(dataStorageManager).getStreamingContent(testSystemDataStorage.getId(), TEST_ATTACHMENT_PATH, null);
}
Aggregations