Skip to content

Commit

Permalink
add delete step
Browse files Browse the repository at this point in the history
  • Loading branch information
atrisovic committed Nov 13, 2021
1 parent ea32432 commit 3e5c567
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
3 changes: 0 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ runs:
run: |
python -m pip install --upgrade pip
pip install -r $GITHUB_ACTION_PATH/requirements.txt
- name: Check repo dir
shell: bash
run: "ls -ls repo/"
- name: Upload files
shell: bash
run: >-
Expand Down
28 changes: 14 additions & 14 deletions dataverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@
api = NativeApi(dataverse_server, dataverse_token)
data_api = DataAccessApi(dataverse_server)

# delete all

#dataset = api.get_dataset(dataverse_dataset_doi)
#files_list = dataset.json()['data']['latestVersion']['files']
#
#delete_api = dataverse_server + \
# '/dvn/api/data-deposit/v1.1/swordv2/edit-media/file/'
#for file in files_list:
# fileid = files_list[1]["dataFile"]["id"]
# resp = requests.delete(
# delete_api + str(fileid), headers={
# 'Authorization' : dataverse_token})

# add all
# the following deletes all the files in the dataset

dataset = api.get_dataset(dataverse_dataset_doi)
files_list = dataset.json()['data']['latestVersion']['files']

delete_api = dataverse_server + \
'/dvn/api/data-deposit/v1.1/swordv2/edit-media/file/'
for f in files_list:
fileid = f["dataFile"]["id"]
resp = requests.delete(
delete_api + str(fileid), \
auth = (dataverse_token , ""))

# the following adds all files from the repository to Dataverse

path='repo'
for f in listdir(path):
Expand Down

0 comments on commit 3e5c567

Please sign in to comment.