Skip to content

Commit b84e74c

Browse files
authored
Merge pull request #54 from GenomicDataInfrastructure/feat/update-readme-for-download
update README about how to download files
2 parents 96f8f77 + fcafafb commit b84e74c

File tree

1 file changed

+35
-3
lines changed

1 file changed

+35
-3
lines changed

README.md

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,40 @@ curl -s -H "Authorization: Bearer $token" "http://localhost:8443/metadata/datase
8888

8989
### Download a specific file
9090

91-
```shell
92-
fileID=$(curl -s -H "Authorization: Bearer $token" "http://localhost:8443/metadata/datasets/$datasetID/files" | jq -r '.[0].fileId')
93-
filename=$(curl -s -H "Authorization: Bearer $token" "http://localhost:8443/metadata/datasets/$datasetID/files" | jq -r '.[0].displayFileName' | cut -d '.' -f 1,2 )
91+
The `sda-download` service offers multiple methods for downloading files through the API, with options for both encrypted and unencrypted results. Below, you will find an example illustrating each of these methods.
92+
93+
To download the file `htsnexus_test_NA12878.bam`, first obtain the respective `fileID` using the following command. The `datasetID`, which is `DATASET0001`, can be obtained by following the instructions at [List datasets](#list-datasets)
94+
95+
```bash
96+
filename="htsnexus_test_NA12878.bam"
97+
fileID=$(curl -s -H "Authorization: Bearer $token" "http://localhost:8443/metadata/datasets/$datasetID/files" | jq -r --arg filename "$filename".c4gh '.[] | select(.displayFileName==$filename) | .fileId')
98+
```
99+
100+
#### 1. Download unencrypted file from the `/files` endpoint
101+
```bash
94102
curl -s -H "Authorization: Bearer $token" http://localhost:8443/files/$fileID -o "$filename"
95103
```
104+
After successful execution, the BAM file `htsnexus_test_NA12878.bam` will be downloaded to your current folder.
105+
106+
#### 2. Download unencrypted file from the `/s3` endpoint
107+
```bash
108+
curl -s -H "Authorization: Bearer $token" http://localhost:8443/s3/$datasetID/$filename -o "$filename"
109+
```
110+
111+
#### 3. Download encrypted file from the `/s3-encrypted` endpoint
112+
To download an encrypted file that is re-encrypted with a custom Crypt4GH public key, you need to first create a key pair by the [`sda-cli`](https://github.com/NBISweden/sda-cli) tool, instructions can be found [here](https://github.com/NBISweden/sda-cli?tab=readme-ov-file#create-keys).
113+
114+
```bash
115+
# create a crypt4gh key pair
116+
sda-cli createKey c4gh
117+
```
118+
```bash
119+
pubkey=$(base64 -w0 c4gh.pub.pem)
120+
curl -s -H "Authorization: Bearer $token" -H "Client-Public-Key: $pubkey" http://localhost:8443/s3-encrypted/$datasetID/$filename -o "$filename.c4gh"
121+
```
122+
123+
After successful execution, the Crypt4GH encrypted BAM file `htsnexus_test_NA12878.bam.c4gh` will be downloaded to your current folder. This file can be decrypted using the private key of the key pair you have created by
124+
125+
```bash
126+
sda-cli decrypt -key c4gh.sec.pem htsnexus_test_NA12878.bam.c4gh
127+
```

0 commit comments

Comments
 (0)