Proof of existence with file upload

Similar to the previous sample application, this sample application also creates a file hash from a local file, posts the file hash to the blockchain, and validates the file hash (to check if the file has been altered.)

This sample application also creates a file asset and uploads it to storage server.

The file from the storage server is then downloaded from the server. The file hash of the downloaded file is checked against the blockchain to see if it exists there.

Run the sample

In a terminal session or in your Docker SDK container, run the sample proof_of_existence_with_fileUpload.js:

node ng-rt-digitalAsset-sdk-samples/examples/usecases/proof_of_existence_with_fileUpload.js

(alias: proofFileUpload)

You should see output similar to this:

[INFO] ng-rt-digitalAsset-sdk.examples.usecases.proof_of_existence_with_fileUpload.js - Creating hash of the file...
[INFO] ng-rt-digitalAsset-sdk.examples.usecases.proof_of_existence_with_fileUpload.js - File hash is stored in the blockchain with transaction id : 02e806c8bd7acdcc03ebd25f59d396404d457add8440faef2b656cbf4c057612
[INFO] ng-rt-digitalAsset-sdk.examples.usecases.proof_of_existence_with_fileUpload.js - File hash exists : esUN7WZgSkKWt7wcoeitoGoMZZfhoPJLQEDUqZ8MkzDU9BP2NcLoM
[INFO] ng-rt-digitalAsset-sdk.examples.usecases.proof_of_existence_with_fileUpload.js - Creating file hash
[INFO] ng-rt-digitalAsset-sdk.examples.usecases.proof_of_existence_with_fileUpload.js - File asset created and file uploaded, file hash is : esUN7WZgSkKWt7wcoeitoGoMZZfhoPJLQEDUqZ8MkzDU9BP2NcLoM
[INFO] ng-rt-digitalAsset-sdk.examples.usecases.proof_of_existence_with_fileUpload.js - Verifying File hash...
[INFO] ng-rt-digitalAsset-sdk.examples.usecases.proof_of_existence_with_fileUpload.js - Check if the downloaded file exists in the blockchain
[INFO] ng-rt-digitalAsset-sdk.examples.usecases.proof_of_existence_with_fileUpload.js - test_file1.txt hash exist in the blockchain
[INFO] ng-rt-digitalAsset-sdk.examples.usecases.proof_of_existence_with_fileUpload.js - test_file2.txt does not exist in the blockchain
[INFO] ng-rt-digitalAsset-sdk.examples.usecases.proof_of_existence_with_fileUpload.js - Downloading file with transaction id : 02e806c8bd7acdcc03ebd25f59d396404d457add8440faef2b656cbf4c057612
[INFO] ng-rt-digitalAsset-sdk.examples.usecases.proof_of_existence_with_fileUpload.js - Downloaded file with the transaction id 02e806c8bd7acdcc03ebd25f59d396404d457add8440faef2b656cbf4c057612 to the path /home/docker/ng-rt-digitalasset-sdk-sample/examples/usecases/files/downloaded
[INFO] ng-rt-digitalAsset-sdk.examples.usecases.proof_of_existence_with_fileUpload.js - create download directory
[INFO] ng-rt-digitalAsset-sdk.examples.usecases.proof_of_existence_with_fileUpload.js - Downloaded file exists in the blockchain

Click here to understand the output of Proof of existence with file upload

Return to Sample Applications