Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

curl: (3) URL using bad/illegal format or missing URL #15

Open
jolespin opened this issue Nov 9, 2023 · 3 comments
Open

curl: (3) URL using bad/illegal format or missing URL #15

jolespin opened this issue Nov 9, 2023 · 3 comments

Comments

@jolespin
Copy link

jolespin commented Nov 9, 2023

Here's my error:

+ ZENODO_TOKEN=[token]
+ DEPOSITION=10081343
+ FILEPATH=S4_scaffolds.fasta.gz
++ echo S4_scaffolds.fasta.gz
++ sed 's+.*/++g'
+ FILENAME=S4_scaffolds.fasta.gz
++ curl -H 'Accept: application/json' -H 'Authorization: Bearer [token]' https://www.zenodo.org/api/deposit/depositions/10081343
++ jq --raw-output .links.bucket
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
+ BUCKET=
+ curl --progress-bar -o /dev/null --upload-file S4_scaffolds.fasta.gz '/S4_scaffolds.fasta.gz?access_token[token]'
curl: (3) URL using bad/illegal format or missing URL

Here's my script:

set -xe
ZENODO_TOKEN=[token]
DEPOSITION=$1
FILEPATH=$2
FILENAME=$(echo $FILEPATH | sed 's+.*/++g')

BUCKET=$(curl -H "Accept: application/json" -H "Authorization: Bearer $ZENODO_TOKEN" "https://www.zenodo.org/api/deposit/depositions/$DEPOSITION" | jq --raw-output .links.bucket)


curl --progress-bar -o /dev/null --upload-file $FILEPATH $BUCKET/$FILENAME?access_token=$ZENODO_TOKEN
@simone-says
Copy link

I'm having the same issue, any update on this?

@jolespin
Copy link
Author

It's a little more complicated now. You gotta follow these instructions: https://developers.zenodo.org/

I ended up running the following script:

BUCKET=https://zenodo.org/api/files/[your-bucket-id]
ACCES_TOKEN=[your-access-token]
FILE=path/to/file
curl --progress-bar --upload-file ${FILE} ${BUCKET}/${FILE}?access_token=$ACCES_TOKEN

I forgot how I got the bucket id but I also have a json file that I don't remember making. That may have been where I got my bucket? It's been a few months since I ran this but that link I posted should have all the info you need.

@jveitchmichaelis
Copy link

Here's a typical workflow you can use in Python, based on the developer docs above. I used this in Colab:

import requests
from google.colab import userdata

ACCESS_TOKEN = userdata.get('ZENODO_TOKEN')
DEPOSITION_ID = <your-id>
r = requests.get(f'https://zenodo.org/api/deposit/depositions/{DEPOSITION_ID}',
                  params={'access_token': ACCESS_TOKEN})
r.status_code
data = r.json()
def upload(filename, path, bucket):
  # This is verbatim from the docs, but they forgot the params section
  with open(path, "rb") as fp:
      r = requests.put(
          "%s/%s" % (bucket, filename),
          data=fp,
          params={'access_token': ACCESS_TOKEN},
      )
  return r.json()

Usage:

upload(file, path, data['links']['bucket'])

Seems to work fine for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants