I have spring boot application which will upload zip file (size > 250MB) to azure blob storage, if file is not directly uploaded to azure then it will use in-memory space which might lead to shortage of memory size in case of multiple requests. So, please give me some reference or code snippet to solve my problem. Thanks.
If you want to directly upload a file to Azure blob, please refer to the following steps
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-storage-blob</artifactId>
<version>12.6.0</version>
</dependency
@PostMapping(path = "/upload")
public String uploadFile(@RequestParam("file") MultipartFile file) throws IOException {
String constr="";
BlobContainerClient container = new BlobContainerClientBuilder()
.connectionString(constr)
.containerName("upload")
.buildClient();
BlobClient blob=container.getBlobClient(file.getOriginalFilename());
blob.upload(file.getInputStream(),file.getSize(),true);
return "ok";
}

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With