Skip to content

Cannot get file upload sample code to work #335

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

Closed
mshamma opened this issue Oct 4, 2017 · 1 comment
Closed

Cannot get file upload sample code to work #335

mshamma opened this issue Oct 4, 2017 · 1 comment

Comments

@mshamma
Copy link

mshamma commented Oct 4, 2017

I'm using the following code in a script and cannot get the sample file upload code to work. I also cannot get a meaningful exception from the Python-Gitlab library. The only exception returned is an AttributeError with a single key 'upload_file'.

Using Python 3.6.2 on macOS

project = gl.projects.get('vogon/bypass')
issue = project.issues.get(42)
try:
    uploaded_file = project.upload_file("the_answer_to_life.txt", 
        filedata="data")
    issue.notes.create({
        "body": "See the [attached file]
            ({})".format(uploaded_file["url"])
    })
except Exception as e:
    self.log.debug(e[0])
@mshamma
Copy link
Author

mshamma commented Oct 4, 2017

Actually it looks like the documentation needs updating:

http://python-gitlab.readthedocs.io/en/stable/gl_objects/projects.html#file-uploads

There are several references to project.upload_file() when it should refer to project.upload()

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant