简体   繁体   中英

PDF to Azure Blob storage

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM