bbc_storage module — BBc1 0.7 documentation

# bbc_storage module

Copyright (c) 2017 beyond-blockchain.org.

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

> http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

`BBcStorage`(config[, core, loglevel, logname]) | Storage manager

class `bbc_storage.` `BBcStorage`(config, core=None, loglevel='all', logname=None)

  Bases: `object`

  Storage manager

  `get_in_filesystem`(domain_id, asset_group_id, asid)

    Get the file with the asset_id in a file system

    Parameters: | domain_id – domain to search in

    :param asset_group_id :param asid: file name :return: the file content (None if not found)

  `get_locally`(domain_id, asset_group_id, asid)

    Get the file with the asset_id from local storage

    Parameters: | domain_id – domain to search in

    :param asset_group_id :param asid: file name :return: the file content (None if not found)

  `get_storage_type`(domain_id, asset_group_id)

    Get storage type for the domain

    Parameters: | domain_id – asset_group_id –
    Returns: |

  `remove`(domain_id, asset_group_id, asid)

    Remove the file with the asset_id

    Parameters: | domain_id –

    :param asset_group_id :param asid: file name :return: True if succeeded

  `set_storage_path`(domain_id, asset_group_id, from_config=False, storage_type=1, storage_path=None)

    Set storage path for the domain

    Parameters: | domain_id –

    :param asset_group_id :param from_config: If True, read setting from config and ignore storage_type and storage_path param :param storage_type: filesystem/HTTP-PUT/HTTP-POST/NONE :param storage_path: directory path or URL :return: True if make dir is successful

  `store_in_filesystem`(domain_id, asset_group_id, asid, content)

    Store data in a file system

    Parameters: | domain_id – domain to put in

    :param asset_group_id :param asid: :param content: :return:

  `store_locally`(domain_id, asset_group_id, asid, content)

    Store data in local storage

    Parameters: | domain_id – domain to put in

    :param asset_group_id :param asid: :param content: :return: