getData: Get FILE with ACL

Reading file with ACL (access control).

API

Z.com Cloud Block Chain / ConoHa Block Chain

Processing Sequence

GetData SomeContract

  • 1 AltExecCnsContract#getFile

    We call AltExecCnsContract from the client logic.

    When calling, parameters are passed including the "name", "function name", "parameter", etc. of the contract to be ultimately called.

  • 1.1 API GET file

    The client module provided by this service signs the hash value derived from all the arguments and does a GET request to the API.

  • 1.1.1 ContractNameService#getLatestcontract

    The API server queries the CNS for the address of the latest version of the contract.

  • 1.1.2 SomeContract#someMethod

    The API server calls the contract as instructed by the end user.
    Here, someMethod should be implemented by the service provider so that it returns the object ID to be downloaded.

  • 1.1.3 isReader

    Within the API server, check using the data on Ethereum that the end user (address) has read permission for the target data.

  • 1.1.4 getData

    Retrieves the hash value of the target data from Ethereum, retrieves the corresponding data from the data store.

  • 1.1.5 getFileName

    As in the case of data, retrieves the hash value of the target file name from Ethereum, retrieves the corresponding file name from the data store, and returns it to the end user.

Implementation by the service provider

  • ClientSide

    • AltExecCnsContract#getFile
    var contract = new AltExecCnsContract(account, '__CNS_ADDRESS__');
    contract.getFile('__PASSWORD__', 'File', 'getObjectId', ['p0', 1, 'p2'], abi, function(err, file) {
        if (err) console.error(err);
        else {
            var link = document.createElement("a");
            document.body.appendChild(link);
            link.href = window.URL.createObjectURL(file);
            link.download = file.name;
            link.click();
            window.URL.revokeObjectUrl(link.href);
            document.body.removeChild(link);
        }
    }
    
    • Contract

    • SomeContract

      The contracts to be implemented are invoked with parameters as specified by the end user, but we implement so that we return the object ID to be acquired as the return value.

      contract SomeContract is VersionContract {
      
          function SomeContract(ContractNameService _cns) VersionContract(_cns, "SomeContract") {}
      
          function someMethod(
                  bytes32 _p0, 
                  uint _p1, 
                  bytes32 _p2) constant returns (bytes32) {
      
              return "objectId0";
          }
      }
      

Note

  • msg.sender

    Calling the constant function is done with the signature of the account for payment.

    "msg.sender" is an account designated to each service provider for payment and is not the end user.

    In Ethereum, the data is basically open, and we consider this in the service (beta version) that the user's authority management is unnecessary regarding the reading process, and the end user's signature check is kept within the API server.

    (However, please understand that there is a possibility that this point will be changed when it is converted to production at the time of the end of beta version.)

  • Simplified implementation

    In the example above, we are implementing logic directly in SomeContract to illustrate the point, but in fact it is necessary to implement it in the form of basic contract configuration.

For details on how to implement the original Contract, refer to the following sources.

results matching ""

    No results matching ""