[GH-ISSUE #48] Uploading isos with api key not possible #22

Closed
opened 2026-02-27 15:46:01 +03:00 by kerem · 7 comments
Owner

Originally created by @lbckmnn on GitHub (Mar 13, 2021).
Original GitHub issue: https://github.com/proxmoxer/proxmoxer/issues/48

I am not sure if this is an issue of proxmoxer or the API itself, but when i try to upload an iso with the following code:

from proxmoxer import ProxmoxAPI

def upload_iso(proxmox_api, iso_path, node: str, storage: str):
    local_storage = proxmox_api.nodes(node).storage(storage)
    iso_file = open(iso_path, 'rb')
    local_storage.upload.create(content='iso', filename=iso_file)

token_value = "xxx"
proxmox_api = ProxmoxAPI("xx.xx.xx.xx:xx", user="token_user@pve",
                                       token_name="token_name", token_value=token_value, verify_ssl=False)
upload_iso(proxmox_api, "/tmp/test.iso", "proxmox", "local")

I get the Exception:

Traceback (most recent call last):
  File "/home/user/proxmox/bug.py", line 23, in <module>
    upload_iso(proxmox, "/tmp/test.iso", "proxmox", "local")
  File  "/home/user/proxmox/bug.py", line 7, in upload_iso
    local_storage.upload.create(content='iso', filename=iso_file)
  File "/usr/lib/python3.9/site-packages/proxmoxer/core.py", line 117, in create
    return self.post(*args, **data)
  File "/usr/lib/python3.9/site-packages/proxmoxer/core.py", line 108, in post
    return self(args)._request("POST", data=data)
  File "/usr/lib/python3.9/site-packages/proxmoxer/core.py", line 90, in _request
    raise ResourceException("{0} {1}: {2} - {3}".format(
proxmoxer.core.ResourceException: 501 Not Implemented: for data too large - b''

When i pass upload_iso an ProxmoxAPI instance, which was created using a "normal" user, uploading the iso works just fine.
The iso itself is only a few Kbytes big and the permissions of the api token are the same as the permissions from the user.
Doing other actions, for example listing the content of a storage, are also no problem with the API Key.

Originally created by @lbckmnn on GitHub (Mar 13, 2021). Original GitHub issue: https://github.com/proxmoxer/proxmoxer/issues/48 I am not sure if this is an issue of proxmoxer or the API itself, but when i try to upload an iso with the following code: ``` python from proxmoxer import ProxmoxAPI def upload_iso(proxmox_api, iso_path, node: str, storage: str): local_storage = proxmox_api.nodes(node).storage(storage) iso_file = open(iso_path, 'rb') local_storage.upload.create(content='iso', filename=iso_file) token_value = "xxx" proxmox_api = ProxmoxAPI("xx.xx.xx.xx:xx", user="token_user@pve", token_name="token_name", token_value=token_value, verify_ssl=False) upload_iso(proxmox_api, "/tmp/test.iso", "proxmox", "local") ``` I get the Exception: ``` Traceback (most recent call last): File "/home/user/proxmox/bug.py", line 23, in <module> upload_iso(proxmox, "/tmp/test.iso", "proxmox", "local") File "/home/user/proxmox/bug.py", line 7, in upload_iso local_storage.upload.create(content='iso', filename=iso_file) File "/usr/lib/python3.9/site-packages/proxmoxer/core.py", line 117, in create return self.post(*args, **data) File "/usr/lib/python3.9/site-packages/proxmoxer/core.py", line 108, in post return self(args)._request("POST", data=data) File "/usr/lib/python3.9/site-packages/proxmoxer/core.py", line 90, in _request raise ResourceException("{0} {1}: {2} - {3}".format( proxmoxer.core.ResourceException: 501 Not Implemented: for data too large - b'' ``` When i pass upload_iso an ProxmoxAPI instance, which was created using a "normal" user, uploading the iso works just fine. The iso itself is only a few Kbytes big and the permissions of the api token are the same as the permissions from the user. Doing other actions, for example listing the content of a storage, are also no problem with the API Key.
kerem 2026-02-27 15:46:01 +03:00
Author
Owner

@jhollowe commented on GitHub (Mar 21, 2021):

This is interesting. I'm thinking this is a PVE bug and not a proxmoxer bug, since we use the same upload code for either authentication method. Since a username/password login works, I would assume that this is not a local problem.

  • What file are you trying to upload?
  • How big is it?
  • Is the file a valid ISO?
  • When using the username/password, does the file get correctly transferred to the server in its entirety?
  • What version of PVE and proxmoxer are you using?

This PVE forum post might be what is going on, but I'm not sure since the username/password works and it is just the token that does not work.

<!-- gh-comment-id:803514293 --> @jhollowe commented on GitHub (Mar 21, 2021): This is interesting. I'm thinking this is a PVE bug and not a proxmoxer bug, since we use the same upload code for either authentication method. Since a username/password login works, I would assume that this is not a local problem. * What file are you trying to upload? * How big is it? * Is the file a valid ISO? * When using the username/password, does the file get correctly transferred to the server in its entirety? * What version of PVE and proxmoxer are you using? [This PVE forum post](https://forum.proxmox.com/threads/api-501-upload-failed-on-nodes-node-storage-storage-upload.58961/) might be what is going on, but I'm not sure since the username/password works and it is just the token that does not work.
Author
Owner

@lbckmnn commented on GitHub (Mar 23, 2021):

What file are you trying to upload?

Initially, I tried to upload a fairly large iso, but I also get the same exception if I try to upload a file which was created with:

cd /tmp/
mkdir testiso
echo "test" > testiso/test.txt
genisoimage testiso/ -o test.iso

So the iso is valid and about as small, as an iso can get.

When using the username/password, does the file get correctly transferred to the server in its entirety?

Yes.

What version of PVE and proxmoxer are you using?

Proxmoxer: 1.1.1
PVE: 6.3-4

<!-- gh-comment-id:804786679 --> @lbckmnn commented on GitHub (Mar 23, 2021): > What file are you trying to upload? Initially, I tried to upload a fairly large iso, but I also get the same exception if I try to upload a file which was created with: ``` cd /tmp/ mkdir testiso echo "test" > testiso/test.txt genisoimage testiso/ -o test.iso ``` So the iso is valid and about as small, as an iso can get. > When using the username/password, does the file get correctly transferred to the server in its entirety? Yes. > What version of PVE and proxmoxer are you using? Proxmoxer: 1.1.1 PVE: 6.3-4
Author
Owner

@encodeltd commented on GitHub (Apr 7, 2021):

Hi, I think this is the same thing that I spent a bit of time looking into a while ago. Basically, the REST API throws 501 Not Implemented, because this method is not implemented in the REST API and the API call only works via SSH/pvesh. I validated that by looking into the API code on my Proxmox node and then I switched my code to do the ISO uploads via SSH/pvesh and everything worked as expected. Hope this helps.

<!-- gh-comment-id:815176691 --> @encodeltd commented on GitHub (Apr 7, 2021): Hi, I think this is the same thing that I spent a bit of time looking into a while ago. Basically, the REST API throws 501 Not Implemented, because this method is not implemented in the REST API and the API call only works via SSH/pvesh. I validated that by looking into the API code on my Proxmox node and then I switched my code to do the ISO uploads via SSH/pvesh and everything worked as expected. Hope this helps.
Author
Owner

@jhollowe commented on GitHub (Apr 9, 2021):

@encodeltd yeah, that is what I was thinking was the problem, but @LukasBec said it worked with standard username/password auth, but not the API key. I'm thinking this is either a PVE issue or an issue with how we are handling API Tokens during a file upload.

@LukasBec could you try uploading a template using both auth methods? I would assume it would have the same issues, but I would like to just double-check.

I've created a related thread on the PVE forums for this issue.

<!-- gh-comment-id:816382980 --> @jhollowe commented on GitHub (Apr 9, 2021): @encodeltd yeah, that is what I was thinking was the problem, but @LukasBec said it worked with standard username/password auth, but not the API key. I'm thinking this is either a PVE issue or an issue with how we are handling API Tokens during a file upload. @LukasBec could you try uploading a template using both auth methods? I would assume it would have the same issues, but I would like to just double-check. I've created a related [thread on the PVE forums](https://forum.proxmox.com/threads/authentication-method-affecting-iso-upload.87334/) for this issue.
Author
Owner

@Fabian-Gruenbichler commented on GitHub (Apr 9, 2021):

(Proxmox dev here)

file uploads with an API token are not supported/implemented yet.

https://git.proxmox.com/?p=pve-manager.git;a=blob;f=PVE/HTTPServer.pm;h=64976c7cba3a50537911bab36e4e484aaf4fd586;hb=HEAD#l80

<!-- gh-comment-id:816493329 --> @Fabian-Gruenbichler commented on GitHub (Apr 9, 2021): (Proxmox dev here) file uploads with an API token are not supported/implemented yet. https://git.proxmox.com/?p=pve-manager.git;a=blob;f=PVE/HTTPServer.pm;h=64976c7cba3a50537911bab36e4e484aaf4fd586;hb=HEAD#l80
Author
Owner

@jhollowe commented on GitHub (Apr 14, 2021):

I've created a Bugzilla bug for this issue as suggested on the forums.

I'll close this issue as this is a PVE issue and it will hopefully get resolved now that there is a bug filed for it.

<!-- gh-comment-id:819816777 --> @jhollowe commented on GitHub (Apr 14, 2021): I've created a [Bugzilla bug](https://bugzilla.proxmox.com/show_bug.cgi?id=3389) for this issue as suggested on the forums. I'll close this issue as this is a PVE issue and it will hopefully get resolved now that there is a bug filed for it.
Author
Owner

@jhollowe commented on GitHub (May 1, 2021):

This issue is fixed in pve-manager >= 6.3-8

<!-- gh-comment-id:830693959 --> @jhollowe commented on GitHub (May 1, 2021): This issue is fixed in pve-manager >= 6.3-8
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/proxmoxer#22
No description provided.