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 the storage server.
The file is then downloaded from the storage 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:
You should see output similar to this:
[INFO] Source Path of the file being uploaded : /ng-rt-digitalAsset-sdk-samples/examples/usecases/files/test_file1.txt
[INFO] Creating hash of the file...
[INFO] File hash is stored in the blockchain with transaction id : 254ae4ef3dde7135bccf82c809255d
[INFO] File hash exists : esUN7WZgSkKWt7wcoeitoGoMZZfhoPJLQEDUqZ8MkzDU9BP2NcLoM
[INFO] Creating file hash
[INFO] File asset created and file uploaded, file hash is : esUN7WZgSkKWt7wcoeitoGoMZZfhoPJLQEDUqZ8MkzDU9BP2NcLoM
[INFO] Verifying if fileAsset test_file1.txt is in the system...
[INFO] test_file1.txt fileAsset exists in the blockchain
[INFO] Verifying if fileAsset test_file2.txt is in the system...
[INFO] test_file2.txt fileAsset does not exist in the blockchain
[INFO] Verifying if fileAsset test_file1_copy.txt is in the system...
[INFO] test_file1_copy.txt fileAsset exists in the blockchain
[INFO] Downloaded file with the transaction id 254ae4ef3dde7135bccf82c809255d... to the path files/downloaded/
[INFO] Verifying if fileAsset downloaded/test_file1.txt is in the system...
[INFO] downloaded/test_file1.txt fileAsset exists in the blockchain