0
votes

There is an example here: https://github.com/corda/blacklist.

First I have run the node using 1. gradlew deployNodes 2. Start the nodes by running runnodes 3. gradlew uploadBlacklist

It showed following message: enter image description here

Now what need to do? How can we see the uploaded and downloaded file. If I open localhost:10006 in browser it is not showing anything.

How to reuse that code in some other project?

1

1 Answers

0
votes

The attachment is referenced in building a transaction:

val txBuilder = TransactionBuilder(notary)
        .addOutputState(agreementState, AGREEMENT_CONTRACT_ID)
        .addCommand(agreeCmd, agreeCmdRequiredSigners)
        .addAttachment(untrustedPartiesAttachment)

Once it is added to the transaction, it can be referenced within the contract:

val attachmentJar = attachment.openAsJAR()
while (attachmentJar.nextEntry.name != "blacklist.txt") {
    // Calling `attachmentJar.nextEntry` causes us to scroll through the JAR.
}
val blacklistedCompanies = mutableListOf<String>()
val bufferedReader = attachmentJar.bufferedReader()
var company = bufferedReader.readLine()
while (company != null) {
    blacklistedCompanies.add(company)
    company = bufferedReader.readLine()
}

You could also extend the client to download the attachment via RPC. See the downloadAttachment method.