com.ch.report.upload.azure.AzureVideoStorageFileUploader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ch-upload Show documentation
Show all versions of ch-upload Show documentation
The Charles Hudson Java FileUploader to cloud storage.
The newest version!
package com.ch.report.upload.azure;
import com.azure.storage.blob.BlobClient;
import com.azure.storage.blob.BlobContainerClient;
import com.azure.storage.blob.BlobContainerClientBuilder;
import com.ch.config.ConfigProperties;
import com.ch.model.SessionReport;
import com.ch.report.upload.FileUploader;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;
public class AzureVideoStorageFileUploader implements FileUploader {
private static final Logger LOGGER = Logger.getLogger(AzureVideoStorageFileUploader.class.getName());
public String upload(File file, ConfigProperties configProperties, SessionReport report) throws Exception {
if (file != null && report != null) {
if (!file.exists() && !file.isFile()) {
return null;
} else {
String sasUrl = configProperties.getProperty("CH_AZURE_VIDEO_BLOB_SAS_URL");
BlobContainerClient blobContainerClient = (new BlobContainerClientBuilder()).endpoint(sasUrl)
.buildClient();
String blobName = file.getName();
BlobClient blobClient = blobContainerClient.getBlobClient(blobName);
blobClient.uploadFromFile(file.getAbsolutePath(), true);
Map metadata = new HashMap();
metadata.put("EXECUTION_ID", report.getExecutionId());
metadata.put("SITE_ID", report.getSite());
blobClient.setMetadata(metadata);
LOGGER.info("Video Report Upload to " + blobClient.getBlobUrl());
return blobClient.getBlobUrl();
}
} else {
return null;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy