pub fn directory_keys_values(
    target: &Target,
    directory: &Path,
    verbose: bool,
) -> Result<(Vec<KeyValuePair>, AssetManifest), failure::Error> {
    let mut upload_vec: Vec<KeyValuePair> = Vec::new();
    let mut asset_manifest: AssetManifest = AssetManifest::new();

    let dir_walker = get_dir_iterator(target, directory)?;

    for entry in dir_walker {
        let entry = entry.unwrap();
        let path = entry.path();
        if path.is_file() {
            if verbose {
                message::working(&format!("Preparing {}", path.display()));
            }

            validate_file_size(&path)?;

            let value = std::fs::read(path)?;

            // Need to base64 encode value
            let b64_value = base64::encode(&value);

            let (url_safe_path, key) =
                generate_path_and_key(path, directory, Some(b64_value.clone()))?;

            validate_key_size(&key)?;

            upload_vec.push(KeyValuePair {
                key: key.clone(),
                value: b64_value,
                expiration: None,
                expiration_ttl: None,
                base64: Some(true),
            });

            asset_manifest.insert(url_safe_path, key);
        }
    }
    Ok((upload_vec, asset_manifest))
}
// Returns the hashed key and value pair for all files in a directory.
Returns the hashed key and value pair for all files in a directory.
Returns the hashed key and value pair for all files in a directory .
pub fn directory_keys_values(
    target: &Target,
    directory: &Path,
    verbose: bool,
) -> Result<(Vec<KeyValuePair>, AssetManifest), failure::Error> {
    let mut upload_vec: Vec<KeyValuePair> = Vec::new();
    let mut asset_manifest: AssetManifest = AssetManifest::new();
    let dir_walker = get_dir_iterator(target, directory)?;
    for entry in dir_walker {
        let entry = entry.unwrap();
        let path = entry.path();
        if path.is_file() {
            if verbose {
                message::working(&format!("Preparing {}", path.display()));
            }
            validate_file_size(&path)?;
            let value = std::fs::read(path)?;
            // Need to base64 encode value
            let b64_value = base64::encode(&value);
            let (url_safe_path, key) =
                generate_path_and_key(path, directory, Some(b64_value.clone()))?;
            validate_key_size(&key)?;
            upload_vec.push(KeyValuePair {
                key: key.clone(),
                value: b64_value,
                expiration: None,
                expiration_ttl: None,
                base64: Some(true),
            });
            asset_manifest.insert(url_safe_path, key);
        }
    }
    Ok((upload_vec, asset_manifest))
}
pub fn directory_keys_values ( target : & Target , directory : & Path , verbose : bool , ) -> Result < ( Vec < KeyValuePair > , AssetManifest ) , failure :: Error > { let mut upload_vec : Vec < KeyValuePair > = Vec :: new ( ) ; let mut asset_manifest : AssetManifest = AssetManifest :: new ( ) ; let dir_walker = get_dir_iterator ( target , directory ) ? ; for entry in dir_walker { let entry = entry . unwrap ( ) ; let path = entry . path ( ) ; if path . is_file ( ) { if verbose { message :: working ( & format ! ( " " path display ( ) ) ) ; } validate_file_size ( & path ) ? ; let value = std :: fs :: read ( path ) ? ; // Need to base64 encode value let b64_value = base64 :: encode ( & value ) ; let ( url_safe_path , key ) = generate_path_and_key ( path , directory , Some ( b64_value . clone ( ) ) ) ? ; validate_key_size ( & key ) ? ; upload_vec . push ( KeyValuePair { key : key . clone ( ) , value : b64_value , expiration : None , expiration_ttl : None , base64 : Some ( true ) , } ) ; asset_manifest . insert ( url_safe_path , key ) ; } } Ok ( ( upload_vec , asset_manifest ) ) }
Returns the hashed key and value pair for all files in a directory.
Returns the hashed key and value pair for all files in a directory .
target
&Target
directory
&Path
verbose
bool