# Upload packages to Nexus repository using python scripts

**URL:** <https://community.sonatype.com/t/upload-packages-to-nexus-repository-using-python-scripts/9807>\
**Category:** Best Practices\
**Tags:** help, nexus-repository, api\
**Created:** [December 22, 2022, 8:36am UTC](https://community.sonatype.com/t/upload-packages-to-nexus-repository-using-python-scripts/9807 "2022-12-22T08:36:42Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![static](https://yyz1.discourse-cdn.com/flex047/user_avatar/community.sonatype.com/static/32/2612_2.png) [@static](https://community.sonatype.com/u/static)\
**Post date:** [March 2, 2023, 6:21pm UTC](https://community.sonatype.com/t/upload-packages-to-nexus-repository-using-python-scripts/9807/3 "2023-03-02T18:21:00Z")

</div>

Thank you for this Niko. I used your code as a reference, but instead of ending up with the actual package.tar.gz file in e.g. repository/hosted-raw/packages/raw I have a text file containing the path & filename. Can you confirm your package is uploaded successfully or if you also just have a text file? Thanks again and good work.

Edit:

I came across [this post](http://community.sonatype.com/t/uploading-packages-to-nexus3-using-python-script/10227) and had to do the following:

```auto
files = {
    'raw.asset1': (myfile, open(myfile, 'rb'))
}

```

This got mine working, but only for text-based files (meaning now it’s the proper contents inside, rather than just the path/filename.ext inside). I’m getting `<Response [500]>` for binary files. I’m still pretty new to python but I suspect it’s the way I’m opening the file, or maybe open isn’t the function I need. I’ll update this thread if I figure it out.

---

_[View the full topic](https://community.sonatype.com/t/upload-packages-to-nexus-repository-using-python-scripts/9807)._
