How to download the files from azure blob storage using java
HOW TO DOWNLOAD THE FILES FROM AZURE BLOB STORAGE USING JAVA
- First, create the CloudStorageAccount object using the STORAGE_CONNECTION_STRING(AccountName and Account Key).
- Create the serviceClient using the CloudStorageAccount object.
- Using the listBlobs method to get all list of objects in the container.
- Using the iterator object to get the details of each object.
- If you want to delete the object using the delete method.
import com.microsoft.azure.storage.CloudStorageAccount;
import com.microsoft.azure.storage.StorageException;
import com.microsoft.azure.storage.blob.CloudBlobClient;
import com.microsoft.azure.storage.blob.CloudBlobContainer;
import com.microsoft.azure.storage.blob.CloudBlockBlob;
import com.microsoft.azure.storage.blob.ListBlobItem;
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.security.InvalidKeyException;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author Janardhan Randhi
* Date : Feb 4 2019
* Description : This class download files from the azure blob storage container.and deleted the file in container.
*
*
*/
public class AzureBlobFileDownload {
public static final String STORAGE_CONNECTION_STRING
= "DefaultEndpointsProtocol=https;"
+ "AccountName=Ram;" //Your account name.
+ "AccountKey=key"; //your account key.
private static final Logger LOGGER = Logger.getLogger(AzureBlobFileDownload.class.getName());
public static void main(String[] args) {
try {
CloudStorageAccount account = CloudStorageAccount.parse(STORAGE_CONNECTION_STRING);
CloudBlobClient serviceClient = account.createCloudBlobClient();
File file = new File("C:\\Users\\Administrator\\Desktop\\SI-Azure_Download");
// File file = new File("D:\\Test");
if (!file.exists()) {
file.mkdir();
}
// Accessing the container to download files
CloudBlobContainer container = serviceClient.getContainerReference("Janardhan");
// Creating a backup container if does not exists.
// CloudBlobContainer container1 = serviceClient.getContainerReference("backupsicontainer");
container.createIfNotExists();
// container1.createIfNotExists();
// Iterating through all the blobs in the container
Iterable blobs = container.listBlobs();
for (ListBlobItem blob : blobs) {
// Accessing the file name from the blobs in the container inorder to create the same in the backup container.
String[] str1 = blob.getUri().toString().split("/");
File f = new File(file.getAbsolutePath() + "\\" +str1[4] );
CloudBlockBlob cloudBlob = (CloudBlockBlob) blob;
// Downloading files from the container
cloudBlob.downloadToFile(f.toString());
cloudBlob.delete();
LOGGER.log(Level.INFO, "File downloaded successfylly & deleted from the container");
break;
}
} catch (StorageException | IOException | URISyntaxException | InvalidKeyException exception) {
LOGGER.log(Level.SEVERE, exception.getMessage());
System.exit(-1);
}
}
}
Thank you Janardhan. Can you provide sample program for reading and writing files within Container. Need to copy file from ContainerA and move to ContainerB.
ReplyDeletewww.omgab.com 우리카지노사이트
ReplyDeletewww.omgab.com/theking 더킹카지노
www.omgab.com/sands 샌즈카지노
www.omgab.com/first 퍼스트카지노
www.omgab.com/yes 예스카지노
www.omgab.com/super 슈퍼카지노
www.omgab.com/gatsby 개츠비카지노
www.omgab.com/33 33카지노
www.omgab.com/world 월드카지노
www.omgab.com/merit 메리트카지노
www.omgka.com 우리카지노사이트
ReplyDeletewww.omgka.com/theking 더킹카지노
www.omgka.com/sands 샌즈카지노
www.omgka.com/first 퍼스트카지노
www.omgka.com/yes 예스카지노
www.omgka.com/super 슈퍼카지노
www.omgka.com/gatsby 개츠비카지노
www.omgka.com/33 33카지노
www.omgka.com/world 월드카지노
www.omgka.com/merit 메리트카지노
www.bbdd66.com 우리카지노사이트
ReplyDeletewww.bbdd66.com/theking 더킹카지노
www.bbdd66.com/sands 샌즈카지노
www.bbdd66.com/first 퍼스트카지노
www.bbdd66.com/yes 예스카지노
www.bbdd66.com/super 슈퍼카지노
www.bbdd66.com/gatsby 개츠비카지노
www.bbdd66.com/33 33카지노
www.bbdd66.com/world 월드카지노
www.bbdd66.com/merit 메리트카지노
www.omgqq.com 우리카지노사이트
ReplyDeletewww.omgqq.com/thekingcasino 더킹카지노
www.omgqq.com/sandscasino 샌즈카지노
www.omgqq.com/firstcasino 퍼스트카지노
www.omgqq.com/yescasino 예스카지노
www.omgqq.com/supercasino 슈퍼카지노
www.omgqq.com/gatsbycasino 개츠비카지노
www.omgqq.com/33casino 33카지노
www.omgqq.com/worldcasino 월드카지노
www.omgqq.com/merit 메리트카지노
Hi,
ReplyDeleteI have a use case to upload larger number of files to my app server hosted in azure app service. Since upload of such huge files can interrupt with application server, we have planned to use Azure storage for storing the files. The files are in.zip format and each zipped folder has around 100 pdf files. Could you please suggest what is the right option to go for. Is it Azure blob storage or File Storage?
I copied your code and tried to compile , but getting the below error, can you please help me out to get rid of this error?
ReplyDeleteError:(47, 38) java: incompatible types: java.lang.Object cannot be converted to com.microsoft.azure.storage.blob.ListBlobItem
Thank You To Give me idea.
ReplyDeleteloft outlet coupon code
After three years of inception, we started to offer sales and services online and established a PTE company incorporated and operating in Singapore. After the entry into UAE, we added oil & gas controls, detectors, and sensors to our portfolio.
ReplyDeleteVisit Website: isolonline
If you want to save a large amount of your money then click the link and make a joyful future for you.
ReplyDeleteKyte Baby discount code
The quickest way to get rid of oily hair is to use the best dry shampoo for oily hair.
ReplyDeletebest dry shampoo for oily hair
This comment has been removed by the author.
ReplyDeleteGet luxury fashion items at discounted prices using the Cettire coupon code and promo codes! Stay Connected With Us For More Offers And Deals.
ReplyDeleteCettire promo code
Get the biggest potential savings by using our Wingstop promo code, Wingstop all-in bundle deals, and many other Wingstop promo codes and coupon codes.
ReplyDeleteHello! I just want to give a huge thumbs up for the great info you have here on this blog. I will be coming back aimed at your website for additional soon. pinterest videos download
ReplyDeleteIt is a great website.. The Design looks very good.. Keep working like that!.
ReplyDeleteCalgary dentist
https://bayanlarsitesi.com/
ReplyDeleteManisa
Denizli
Malatya
Çankırı
RAJB
Iğdır
ReplyDeleteAdana
Karabük
Diyarbakır
Antep
2BPF
bitlis
ReplyDeletesakarya
van
tunceli
ankara
FJHDZ2
bitlis
ReplyDeletekastamonu
çorum
van
sakarya
6QQTQ
ankara parça eşya taşıma
ReplyDeletetakipçi satın al
antalya rent a car
antalya rent a car
ankara parça eşya taşıma
GXU17
denizli evden eve nakliyat
ReplyDeletekars evden eve nakliyat
çorum evden eve nakliyat
kars evden eve nakliyat
malatya evden eve nakliyat
8AZ5
48F3B
ReplyDeleteKeçiören Fayans Ustası
Kırklareli Parça Eşya Taşıma
Çerkezköy Organizasyon
Ankara Asansör Tamiri
Aydın Lojistik
Çerkezköy Petek Temizleme
Rize Parça Eşya Taşıma
Amasya Parça Eşya Taşıma
Zonguldak Parça Eşya Taşıma
E50CE
ReplyDeletebuy halotestin
sarms for sale
buy trenbolone enanthate
order clenbuterol
halotestin for sale
buy testosterone propionat
sustanon for sale
peptides
buy winstrol stanozolol
58E1D
ReplyDeleteKarabük Şehir İçi Nakliyat
Pursaklar Fayans Ustası
Eskişehir Şehirler Arası Nakliyat
Btcst Coin Hangi Borsada
Adana Parça Eşya Taşıma
Ünye Halı Yıkama
Bitlis Evden Eve Nakliyat
Kırklareli Şehir İçi Nakliyat
Urfa Evden Eve Nakliyat
F6483
ReplyDeleteHexa Coin Hangi Borsada
Tekirdağ Parça Eşya Taşıma
Mith Coin Hangi Borsada
Antep Lojistik
Batman Şehir İçi Nakliyat
Erzincan Parça Eşya Taşıma
Edirne Şehirler Arası Nakliyat
Mercatox Güvenilir mi
Adıyaman Evden Eve Nakliyat
40ACA
ReplyDeleteTekirdağ Canlı Görüntülü Sohbet
balıkesir canlı sohbet siteleri
konya sohbet chat
kars bedava sohbet uygulamaları
ardahan random görüntülü sohbet
elazığ kadınlarla rastgele sohbet
kırşehir yabancı görüntülü sohbet siteleri
giresun sesli sohbet sesli chat
ankara parasız sohbet
01BB4
ReplyDeleteKripto Para Kazma
Kripto Para Çıkarma Siteleri
Discord Sunucu Üyesi Hilesi
Aion Coin Hangi Borsada
Referans Kimliği Nedir
Coin Madenciliği Nedir
Görüntülü Sohbet Parasız
Bonk Coin Hangi Borsada
Facebook Takipçi Satın Al
306FF
ReplyDeleteshiba
phantom
poocoin
pancakeswap
layerzero
zkswap
metamask
trezor suite
poocoin
A11A4
ReplyDeletephantom wallet
pancakeswap
DefiLlama
eigenlayer
bscpad
spookyswap
debank
pancakeswap
trezor suite
B3F0A
ReplyDeletegate io
telegram en iyi kripto grupları
binance referans kodu
kraken
ilk kripto borsası
copy trade nedir
referans kimligi nedir
canlı sohbet
rastgele canlı sohbet
A5ABE
ReplyDeletemobil proxy 4g
mexc
bitcoin hangi bankalarda var
bingx
referans kodu
gate io
binance
gate io
4g proxy
5E34E
ReplyDeletebitexen
4g proxy
binance referans kimliği nedir
binance
telegram kripto para
canlı sohbet ucretsiz
btcturk
bingx
bibox