use of com.azure.storage.blob.models.BlobHttpHeaders in project vidflow-backend by CryptoSingh1337.
the class VideoOperationsServiceImpl method uploadVideo.
@Override
public List<String> uploadVideo(String username, MultipartFile videoFile) {
if (validateVideoFileType(videoFile.getContentType())) {
log.debug("Uploading video...");
List<String> videoDetails = new ArrayList<>(2);
String id = new ObjectId().toString();
videoDetails.add(id);
BlobClient blobClient = blobContainerClient.getBlobClient(generateUploadBlobName(username, id, getFileType(Objects.requireNonNull(videoFile.getOriginalFilename()))));
try {
BlobParallelUploadOptions blobParallelUploadOptions = new BlobParallelUploadOptions(videoFile.getInputStream());
blobParallelUploadOptions.setHeaders(new BlobHttpHeaders().setContentType(videoFile.getContentType()));
blobClient.uploadWithResponse(blobParallelUploadOptions, null, Context.NONE);
videoDetails.add(blobClient.getBlockBlobClient().getBlobUrl());
return videoDetails;
} catch (IOException ignored) {
throw new UploadFailedException("Video is unable to upload");
}
} else {
throw new UnsupportedFormatException("Unsupported video format");
}
}
use of com.azure.storage.blob.models.BlobHttpHeaders in project vidflow-backend by CryptoSingh1337.
the class ThumbnailOperationsServiceImpl method uploadThumbnail.
@Override
public String uploadThumbnail(String username, String videoId, MultipartFile thumbnail) {
if (validateImageFileType(thumbnail.getContentType())) {
log.debug("Uploading thumbnail...");
BlobClient blobClient = containerClient.getBlobClient(generateBlobName(username, videoId, getFileType(Objects.requireNonNull(thumbnail.getOriginalFilename()))));
try {
BlobParallelUploadOptions blobParallelUploadOptions = new BlobParallelUploadOptions(thumbnail.getInputStream());
blobParallelUploadOptions.setHeaders(new BlobHttpHeaders().setContentType(thumbnail.getContentType()));
blobClient.uploadWithResponse(blobParallelUploadOptions, null, Context.NONE);
return blobClient.getBlockBlobClient().getBlobUrl();
} catch (IOException e) {
throw new UploadFailedException("Thumbnail is unable to upload");
}
} else {
throw new UnsupportedFormatException("Unsupported thumbnail format");
}
}
use of com.azure.storage.blob.models.BlobHttpHeaders in project conductor by Netflix.
the class AzureBlobPayloadStorage method upload.
/**
* Uploads the payload to the given azure blob name.
* It is expected that the caller retrieves the blob name
* using {@link #getLocation(Operation, PayloadType, String)} before making this call.
*
* @param path the name of the blob to be uploaded
* @param payload an {@link InputStream} containing the json payload which is to be uploaded
* @param payloadSize the size of the json payload in bytes
*/
@Override
public void upload(String path, InputStream payload, long payloadSize) {
try {
BlockBlobClient blockBlobClient = blobContainerClient.getBlobClient(path).getBlockBlobClient();
BlobHttpHeaders blobHttpHeaders = new BlobHttpHeaders().setContentType(CONTENT_TYPE);
blockBlobClient.uploadWithResponse(payload, payloadSize, blobHttpHeaders, null, null, null, null, null, Context.NONE);
} catch (BlobStorageException | UncheckedIOException | UnexpectedLengthException e) {
String msg = "Error communicating with Azure";
logger.error(msg, e);
throw new ApplicationException(ApplicationException.Code.BACKEND_ERROR, msg, e);
}
}
use of com.azure.storage.blob.models.BlobHttpHeaders in project ApplicationInsights-Java by microsoft.
the class ServiceProfilerUploader method createBlockBlobOptions.
BlobUploadFromFileOptions createBlockBlobOptions(File file, UploadContext uploadContext) {
HashMap<String, String> metadata = new HashMap<>();
metadata.put(BlobMetadataConstants.DATA_CUBE_META_NAME, uploadContext.getDataCube().toString().toLowerCase());
metadata.put(BlobMetadataConstants.MACHINE_NAME_META_NAME, uploadContext.getMachineName());
metadata.put(BlobMetadataConstants.START_TIME_META_NAME, TimestampContract.timestampToString(uploadContext.getSessionId()));
metadata.put(BlobMetadataConstants.PROGRAMMING_LANGUAGE_META_NAME, "Java");
metadata.put(BlobMetadataConstants.OS_PLATFORM_META_NAME, OsPlatformProvider.getOsPlatformDescription());
metadata.put(BlobMetadataConstants.TRACE_FILE_FORMAT_META_NAME, "jfr");
if (roleName != null && !roleName.isEmpty()) {
metadata.put(BlobMetadataConstants.ROLE_NAME_META_NAME, roleName);
}
String fullFilePath = file.getAbsoluteFile().toString();
return new BlobUploadFromFileOptions(fullFilePath).setHeaders(new BlobHttpHeaders().setContentEncoding("gzip")).setMetadata(metadata).setParallelTransferOptions(new ParallelTransferOptions().setBlockSizeLong(UPLOAD_BLOCK_LENGTH));
}
Aggregations