# Unable to upload zip.bin file using uri module

**URL:** <https://forum.ansible.com/t/unable-to-upload-zip-bin-file-using-uri-module/38825>\
**Category:** Ansible Project\
**Created:** [July 15, 2024, 1:21pm UTC](https://forum.ansible.com/t/unable-to-upload-zip-bin-file-using-uri-module/38825 "2024-07-15T13:21:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![batchenr](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/batchenr/32/7123_2.png) [@batchenr](https://forum.ansible.com/u/batchenr)\
**Post date:** [July 15, 2024, 1:21pm UTC](https://forum.ansible.com/t/unable-to-upload-zip-bin-file-using-uri-module/38825/1 "2024-07-15T13:21:10Z")

</div>

Im tring to translate a play i have that is using curl to use uri and nothing works for me  
this is the what works for now:

# - name: install via shell

# shell: “curl -k --fail --connect-timeout 1 --max-time 1200 -X "POST" "[https://127.0.0.1:8080/v0/upload\](https://127.0.0.1:8080/v0/upload%5C)” -H "Authorization: Bearer {{ login.json.access\_token }}" -H "Content-Type: multipart/form-data" -F "in\_file=@/home/user/bundles/{{ item.key }}\_docker.zip.bin""

# loop: “{{ template|dict2items }}”

now i have translated this to uri:

- name: install  
become: yes  
uri:  
url: “[https://127.0.0.1:8080/v0/upload](https://127.0.0.1:8080/v0/upload)”  
headers:  
Authorization: “Bearer {{ login.json.access\_token }}”  
Accept: application/json  
Content-Type: multipart/form-data  
validate\_certs: no  
body\_format: form-multipart  
method: POST  
timeout: 1200  
remote\_src: yes  
body:  
in\_file:  
filename: “/home/user/bundles/{{ item.key }}\_docker.zip.bin”  
mime\_type: application/octet-stream  
loop: “{{ template | dict2items }}”

because this file is encrypted for some reason the uri module doesnt upload it correctly  
in my server that the file is posted to , need to run some decryped script  
and the file using the uri module is uploaded as not binary file if i open it - it looks like a certificate file inside and also the file size is bigger

if i uploads it using curl and open the file i can see the file is binary file and the file size is smaller  
what is hapening? why is the uri module changing the file?

please help?

---

<div class="post-metadata">

**Author:** ![batchenr](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/batchenr/32/7123_2.png) [@batchenr](https://forum.ansible.com/u/batchenr)\
**Post date:** [July 16, 2024, 9:37am UTC](https://forum.ansible.com/t/unable-to-upload-zip-bin-file-using-uri-module/38825/2 "2024-07-16T09:37:51Z")

</div>

also the correct file type is seen as “data” when uploaded and from uri it is uploaded as ASCII

ansible==2.10.5  
ansible-base==2.10.17

ב-יום שני, 15 ביולי 2024 בשעה 16:21:10 UTC+3, R Batchen כתב/ה:

---

<div class="post-metadata">

**Author:** ![batchenr](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/batchenr/32/7123_2.png) [@batchenr](https://forum.ansible.com/u/batchenr)\
**Post date:** [August 7, 2024, 11:09am UTC](https://forum.ansible.com/t/unable-to-upload-zip-bin-file-using-uri-module/38825/3 "2024-08-07T11:09:05Z")

</div>

well i got my anser in ansible github - it is impossible at a moment to post bin files using uri  
thnks

ב-יום שלישי, 16 ביולי 2024 בשעה 12:37:51 UTC+3, R Batchen כתב/ה:

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [August 7, 2024, 3:01pm UTC](https://forum.ansible.com/t/unable-to-upload-zip-bin-file-using-uri-module/38825/4 "2024-08-07T15:01:46Z")

</div>

That is not a correct assessment of the issue. The server software handling the upload is incapable of utilizing the Content-Transfer-Encoding of multipart form data, and the python standard lib code is only capable of sending binary data with a base64 (or similar) encoding.

It is possible, but may be dependent on the server software that is receiving the data.
