use of org.talend.components.azurestorage.blob.helpers.RemoteBlobGet in project components by Talend.
the class RemoteBlobTest method setUp.
@Before
public void setUp() throws Exception {
remoteBlob = new RemoteBlob("", true);
remoteBlobGet = new RemoteBlobGet("", true, true);
remoteBlobGet2 = new RemoteBlobGet("", true);
}
use of org.talend.components.azurestorage.blob.helpers.RemoteBlobGet in project components by Talend.
the class AzureStorageGetRuntime method createRemoteBlobsGet.
public List<RemoteBlobGet> createRemoteBlobsGet() {
List<RemoteBlobGet> remoteBlobs = new ArrayList<>();
for (int idx = 0; idx < remoteBlobsGet.prefix.getValue().size(); idx++) {
String prefix = "";
boolean include = false;
boolean create = false;
if (remoteBlobsGet.prefix.getValue().get(idx) != null) {
prefix = remoteBlobsGet.prefix.getValue().get(idx);
}
if (remoteBlobsGet.include.getValue().get(idx) != null) {
include = remoteBlobsGet.include.getValue().get(idx);
}
if (remoteBlobsGet.create.getValue().get(idx) != null) {
create = remoteBlobsGet.create.getValue().get(idx);
}
remoteBlobs.add(new RemoteBlobGet(prefix, include, create));
}
return remoteBlobs;
}
use of org.talend.components.azurestorage.blob.helpers.RemoteBlobGet in project components by Talend.
the class AzureStorageGetRuntime method download.
private void download(RuntimeContainer runtimeContainer) {
FileOutputStream fos = null;
try {
List<RemoteBlobGet> remoteBlobs = createRemoteBlobsGet();
for (RemoteBlobGet rmtb : remoteBlobs) {
for (ListBlobItem blob : azureStorageBlobService.listBlobs(containerName, rmtb.prefix, rmtb.include)) {
if (blob instanceof CloudBlob) {
// TODO - Action when create is false and include is true ???
if (rmtb.create) {
new File(localFolder + "/" + ((CloudBlob) blob).getName()).getParentFile().mkdirs();
}
fos = new FileOutputStream(localFolder + "/" + ((CloudBlob) blob).getName());
azureStorageBlobService.download((CloudBlob) blob, fos);
}
}
}
} catch (StorageException | URISyntaxException | FileNotFoundException | InvalidKeyException e) {
LOGGER.error(e.getLocalizedMessage());
if (dieOnError) {
throw new ComponentException(e);
}
} finally {
try {
fos.close();
} catch (Exception e) {
// ignore
}
}
}
Aggregations