-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathremote_upload.sh
More file actions
32 lines (26 loc) · 1.2 KB
/
remote_upload.sh
File metadata and controls
32 lines (26 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# DVCLI Remote Upload
#
# Please note, this recipe assumes that you are already familiar with
# DVCLI authentication. If you are not, please refer to the authentication.sh
# recipe or use the environment variables DVCLI_TOKEN and DVCLI_URL.
#
# This script demonstrates how to upload a file from a remote URL to a dataset.
# The remote URL should point to a file that is hosted somewhere on the internet.
# When using a remote url, you need to provide a path and filename for the file
# using the --dv-path flag. Otherwise, DVCLI will not know where to store the
# file in the dataset and throw an error.
# Upload the file from a remote URL
REMOTE_URL=https://raw.githubusercontent.com/gdcc/rust-dataverse/refs/heads/master/Readme.md
# Create a dataset
dvcli -p local dataset create --body bodies/dataset.json --collection root >dataset_response.json
# Grab the dataset pid from the response
dataset_pid=$(jq -r '.persistentId' dataset_response.json)
# Upload the file from a remote URL
dvcli -p local dataset upload \
--id $dataset_pid \
--dv-path readme.md \
$REMOTE_URL
# List the files in the dataset
dvcli -p local dataset list-files $dataset_pid
# Clean up the response file
rm dataset_response.json