So far, we have performed a file transfer on a local machine using the Eclipse Dataspace Connector. While that is already great progress, it probably won't be much use in a real-world production application.
This chapter improves on this by shifting the file transfer between cloud storage emulators. We will now:
- read the source from an Azurite instance,
- put the destination file into a MinIO instance.
The following steps assume that you have Docker, Vault and the Azure CLI installed. If this is not the case, you can use the following links to access the installation instructions for all three.
- Docker: https://docs.docker.com/engine/install/
- Vault: https://developer.hashicorp.com/vault/docs/install
- Azure CLI: https://learn.microsoft.com/en-us/cli/azure/install-azure-cli
docker compose -f transfer/transfer-05-file-transfer-cloud/resources/docker-compose.yaml up -d
Please check in the logs that minio, azurite and hashicorp-vault have started correctly.
Go to http://localhost:9001 and login with the credentials which you can find in the docker-compose file (line 20-21), then go to 'Buckets' and create a bucket with the name “src-bucket”.
Let`s create a container with the following commands:
conn_str="DefaultEndpointsProtocol=http;AccountName=provider;AccountKey=password;BlobEndpoint=http://127.0.0.1:10000/provider;"
az storage container create --name src-container --connection-string $conn_str
If the container is created successfully, you will get this:
{
"created": true
}
Upload the file to the blob storage:
az storage blob upload -f ./transfer/transfer-05-file-transfer-cloud/resources/test-document.txt --container-name src-container --name test-document.txt --connection-string $conn_str
You can run the following command to check if the file was added successfully
az storage blob list --container-name src-container --connection-string "DefaultEndpointsProtocol=http;AccountName=provider;AccountKey=password;BlobEndpoint=http://127.0.0.1:10000/provider;" --query "[].{name:name}" --output table
You should see the test-document.txt file.
Name
--------------------------
test-document.txt
We already started the vault at the beginning with docker compose. Now the following commands must be executed in a terminal window to add the necessary secrets.
export VAULT_ADDR='http://0.0.0.0:8200'
vault kv put secret/accessKeyId content=consumer
vault kv put secret/secretAccessKey content=password
vault kv put secret/provider-key content=password
./gradlew clean build
java -Dedc.fs.config=transfer/transfer-05-file-transfer-cloud/cloud-transfer-provider/config.properties -jar transfer/transfer-05-file-transfer-cloud/cloud-transfer-provider/build/libs/provider.jar
# in another terminal window:
java -Dedc.fs.config=transfer/transfer-05-file-transfer-cloud/cloud-transfer-consumer/config.properties -jar transfer/transfer-05-file-transfer-cloud/cloud-transfer-consumer/build/libs/consumer.jar
curl -X POST "http://localhost:29193/management/v3/catalog/request" \
-H 'X-Api-Key: password' -H 'Content-Type: application/json' \
-d @transfer/transfer-05-file-transfer-cloud/resources/fetch-catalog.json -s | jq
Please replace the {{contract-offer-id}} placeholder in the negotiate-contract.json file with the contract offer id you found in the catalog at the path dcat:dataset.odrl:hasPolicy.@id (the asset with "@id: 1").
curl -d @transfer/transfer-05-file-transfer-cloud/resources/negotiate-contract.json \
-H 'X-Api-Key: password' X POST -H 'content-type: application/json' http://localhost:29193/management/v3/contractnegotiations \
-s | jq
We can now use the UUID to check the current status of the negotiation using an endpoint on the consumer side.
curl -X GET "http://localhost:29193/management/v3/contractnegotiations/{{contract-negotiation-id}}" \
-H 'X-Api-Key: password' --header 'Content-Type: application/json' \
-s | jq
Please replace the {{contract-agreement-id}} placeholder in the start-transfer.json file with the contractAgreementId from the previous response.
curl -X POST "http://localhost:29193/management/v3/transferprocesses" \
-H 'X-Api-Key: password' -H "Content-Type: application/json" \
-d @transfer/transfer-05-file-transfer-cloud/resources/start-transfer.json \
-s | jq
With the given UUID, we can check the transfer process.
curl -H 'X-Api-Key: password' http://localhost:29193/management/v3/transferprocesses/<transfer-process-id> -s | jq
Execute the following command in a terminal window to stop the docker container:
docker compose -f transfer/transfer-05-file-transfer-cloud/resources/docker-compose.yaml down