Skip to content
This repository was archived by the owner on Oct 6, 2020. It is now read-only.

Commit 48f8e14

Browse files
authored
Merge pull request #145 from ctaggart/count_blobs
add count_blobs example
2 parents 598f4d9 + 2be6c76 commit 48f8e14

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
use azure_sdk_core::prelude::*;
2+
use azure_sdk_storage_blob::prelude::*;
3+
use azure_sdk_storage_core::prelude::*;
4+
use futures::Stream;
5+
use std::error::Error;
6+
use tokio_core::reactor::Core;
7+
8+
fn main() {
9+
code().unwrap();
10+
}
11+
12+
fn code() -> Result<(), Box<dyn Error>> {
13+
let account = std::env::var("STORAGE_ACCOUNT").expect("Set env variable STORAGE_ACCOUNT first!");
14+
let master_key = std::env::var("STORAGE_MASTER_KEY").expect("Set env variable STORAGE_MASTER_KEY first!");
15+
16+
let container = std::env::args()
17+
.nth(1)
18+
.expect("please specify container name as command line parameter");
19+
20+
let mut core = Core::new()?;
21+
let client = Client::new(&account, &master_key)?;
22+
23+
let mut count = 0;
24+
let list_blobs = client.stream_list_blobs().with_container_name(&container);
25+
let future = list_blobs.finalize().for_each(|_blob| {
26+
count += 1;
27+
Ok(())
28+
});
29+
core.run(future)?;
30+
31+
println!("blob count {}", count);
32+
33+
Ok(())
34+
}

0 commit comments

Comments
 (0)