pub async fn command_upload_bundles(
    arweave: &Arweave,
    glob_str: &str,
    log_dir: Option<String>,
    tags: Option<Vec<Tag<String>>>,
    bundle_size: u64,
    reward_mult: f32,
    output_format: Option<&str>,
    buffer: usize,
) -> CommandResult {
    let paths_iter = glob(glob_str)?.filter_map(Result::ok);
    let log_dir = log_dir.map(|s| PathBuf::from(s)).unwrap();
    let output_format = get_output_format(output_format.unwrap_or(""));
    let tags = tags.unwrap_or(Vec::new());
    let price_terms = arweave.get_price_terms(reward_mult).await?;
    let path_chunks = arweave.chunk_file_paths(paths_iter, bundle_size)?;

    if path_chunks.len() == 0 {
        println!("The pattern \"{}\" didn't match any files.", glob_str);
        return Ok(());
    } else {
        let mut stream = upload_bundles_stream(arweave, path_chunks, tags, price_terms, buffer);

        let mut counter = 0;
        let mut number_of_files = 0;
        let mut data_size = 0;
        while let Some(result) = stream.next().await {
            match result {
                Ok(status) => {
                    number_of_files += status.number_of_files;
                    data_size += status.data_size;
                    if counter == 0 {
                        println!("{}", status.header_string(&output_format));
                    }
                    print!("{}", output_format.formatted_string(&status));
                    fs::write(
                        log_dir.join(status.id.to_string()).with_extension("json"),
                        serde_json::to_string(&status)?,
                    )
                    .await?;
                    counter += 1;
                }
                Err(e) => println!("{:#?}", e),
            }
        }

        println!(
            "\nUploaded {} KB in {} files in {} bundle transactions. Run `arloader update-status --log-dir \"{}\"` to update statuses.",
            data_size / 1000,
            number_of_files,
            counter,
            log_dir.display().to_string()
        );
    }
    Ok(())
}
/// Uploads bundles created from provided glob to Arweave.
Uploads bundles created from provided glob to Arweave.
Uploads bundles created from provided glob to Arweave .
pub async fn command_upload_bundles(
    arweave: &Arweave,
    glob_str: &str,
    log_dir: Option<String>,
    tags: Option<Vec<Tag<String>>>,
    bundle_size: u64,
    reward_mult: f32,
    output_format: Option<&str>,
    buffer: usize,
) -> CommandResult {
    let paths_iter = glob(glob_str)?.filter_map(Result::ok);
    let log_dir = log_dir.map(|s| PathBuf::from(s)).unwrap();
    let output_format = get_output_format(output_format.unwrap_or(""));
    let tags = tags.unwrap_or(Vec::new());
    let price_terms = arweave.get_price_terms(reward_mult).await?;
    let path_chunks = arweave.chunk_file_paths(paths_iter, bundle_size)?;
    if path_chunks.len() == 0 {
        println!("The pattern \"{}\" didn't match any files.", glob_str);
        return Ok(());
    } else {
        let mut stream = upload_bundles_stream(arweave, path_chunks, tags, price_terms, buffer);
        let mut counter = 0;
        let mut number_of_files = 0;
        let mut data_size = 0;
        while let Some(result) = stream.next().await {
            match result {
                Ok(status) => {
                    number_of_files += status.number_of_files;
                    data_size += status.data_size;
                    if counter == 0 {
                        println!("{}", status.header_string(&output_format));
                    }
                    print!("{}", output_format.formatted_string(&status));
                    fs::write(
                        log_dir.join(status.id.to_string()).with_extension("json"),
                        serde_json::to_string(&status)?,
                    )
                    .await?;
                    counter += 1;
                }
                Err(e) => println!("{:#?}", e),
            }
        }
        println!(
            "\nUploaded {} KB in {} files in {} bundle transactions. Run `arloader update-status --log-dir \"{}\"` to update statuses.",
            data_size / 1000,
            number_of_files,
            counter,
            log_dir.display().to_string()
        );
    }
    Ok(())
}
pub async fn command_upload_bundles ( arweave : & Arweave , glob_str : & str , log_dir : Option < String > , tags : Option < Vec < Tag < String > > > , bundle_size : u64 , reward_mult : f32 , output_format : Option < & str > , buffer : usize , ) -> CommandResult { let paths_iter = glob ( glob_str ) ? . filter_map ( Result :: ok ) ; let log_dir = log_dir . map ( | s | PathBuf :: from ( s ) ) . unwrap ( ) ; let output_format = get_output_format ( output_format . unwrap_or ( " " ) ) ; let tags = tags . unwrap_or ( Vec :: new ( ) ) ; let price_terms = arweave . get_price_terms ( reward_mult ) . await ? ; let path_chunks = arweave . chunk_file_paths ( paths_iter , bundle_size ) ? ; if path_chunks . len ( ) == 0 { println ! ( " \" \" " glob_str ) ; return Ok ( ( ) ) ; } else { let mut stream = upload_bundles_stream ( arweave , path_chunks , tags , price_terms , buffer ) ; let mut counter = 0 ; let mut number_of_files = 0 ; let mut data_size = 0 ; while let Some ( result ) = stream . next ( ) . await { match result { Ok ( status ) => { number_of_files += status . number_of_files ; data_size += status . data_size ; if counter == 0 { println ! ( " " status header_string ( output_format ) ) ; } print ! ( " " output_format formatted_string ( status ) ) ; fs :: write ( log_dir . join ( status . id . to_string ( ) ) . with_extension ( " " ) , serde_json :: to_string ( & status ) ? , ) . await ? ; counter += 1 ; } Err ( e ) => println ! ( " " e ) , } } println ! ( " \n \" \" " data_size 1000 number_of_files counter log_dir display ( ) to_string ( ) ) ; } Ok ( ( ) ) }
Uploads bundles created from provided glob to Arweave.
Uploads bundles created from provided glob to Arweave .
arweave
&Arweave
glob_str
&str
log_dir
Option<String>
tags
Option<Vec<Tag<String>>>
bundle_size
u64
reward_mult
f32
output_format
Option<&str>
buffer
usize
arweave
&Arweave
glob_str
&str
log_dir
Option<String>
tags
Option<Vec<Tag<String>>>
bundle_size
u64
reward_mult
f32
output_format
Option<&str>
buffer
usize