UrielCh / proxmox-api

TypeScript Api for proxmox
59 stars 15 forks source link

Unable to upload template file to proxmox #32

Open mfung37 opened 4 months ago

mfung37 commented 4 months ago

The /api2/json/nodes/{node}/storage/{storage}/upload api endpoint appears to require the content-type to be multipart/form-data to be able to upload a file. The following curl command is able to upload the <iso_filename> to proxmox server.

curl -k -X POST -H 'Authorization: PVEAPIToken=<PROXMOX_TOKEN_ID>=<PROXMOX_TOKEN_SECRET>' -H "multipart/form-data" --form "content=iso" --form "filename=@<iso_filename>" https://<PROXMOX_ENDPOINT>/api2/json/nodes/<NODE>/storage/<STORAGE>/upload

If a json format, which the repo uses with application/x-www-urlencoded, is used instead, it returns a HTTP 502 error. This might be due to it not expecting a json format. Currently, it doesn't appear possible to upload a file using the proxmox endpoint.

As reference, Post with REST api on this endpoint and Proxmox api documentation

From me and @williamhatcher

Sephyi commented 2 months ago

I'm planning to implement this feature in my project. Once I reach that stage, I'll have more insights and practical experience to share. I'll make sure to update this thread as soon as I do.