PDF to Azure Blob storage

Viewed 29

I have requirement where I need to upload a pdf to Azure Blob. I have it pdf in base64 encoded form. Application do not have any storage. Is it possible to convert base64 to pdf and upload it as pdf without storing it in any location using java code.

1 Answers

Yes, it's possible to upload a file (PDF) into Azure Storage Account using Java, you need to use Azure Blob Storage client library for Java provided by Microsoft. A couple of links to get you started;

Microsoft Documentation: Manage blobs with Java v12 SDK

Azure Storage libraries for Java

Microsoft Documentation: Sample code

// Create a local file in the ./data/ directory for uploading and downloading
String localPath = "./data/";
String fileName = "quickstart" + java.util.UUID.randomUUID() + ".txt";
File localFile = new File(localPath + fileName);

// Write text to the file
FileWriter writer = new FileWriter(localPath + fileName, true);
writer.write("Hello, World!");
writer.close();

// Get a reference to a blob
BlobClient blobClient = containerClient.getBlobClient(fileName);

System.out.println("\nUploading to Blob storage as blob:\n\t" + blobClient.getBlobUrl());

// Upload the blob
blobClient.uploadFromFile(localPath + fileName);

If this information helps you get going then consider accepting this answer and do a up vote, if not then provide your feedback. Thanks.

Related