# Files become corrupt when trying to upload using REST API

**URL:** https://meta.discourse.org/t/files-become-corrupt-when-trying-to-upload-using-rest-api/223181
**Category:** Support
**Created:** [April 4, 2022, 4:36pm UTC](https://meta.discourse.org/t/files-become-corrupt-when-trying-to-upload-using-rest-api/223181 "2022-04-04T16:36:17Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Devarsh\_Mavani](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/devarsh_mavani/32/251071_2.png) [@Devarsh\_Mavani](https://meta.discourse.org/u/Devarsh_Mavani)
#### Post date: [April 4, 2022, 4:36pm UTC](https://meta.discourse.org/t/files-become-corrupt-when-trying-to-upload-using-rest-api/223181/1 "2022-04-04T16:36:18Z")

</div>

I have setup discourse locally. I am trying to upload files using rest api.

here is the http headers and info from postman

```plaintext
POST /uploads.json HTTP/1.1
Host: localhost:4200
Api-Key: 3772adba123b1db43f4d3644382b97a5ba9b6cdfdb796e25341dc796c402638e
Api-Username: devarshmavani19
Cache-Control: no-cache
Postman-Token: 57530e28-fe64-a899-dfb3-80271a47ad31
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW

------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="type"

pdf
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="synchronous"

true
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="file"; filename="helloworld.pdf"
Content-Type: 

------WebKitFormBoundary7MA4YWxkTrZu0gW--

```

as shown the type is PDF and synchnouse is set to true.  
but when i attach this file in post like this

```plaintext
[helloworld.pdf|attachment](upload://fechbEeCLVWfqlriiLsIKEu1wdg.pdf) (1.36 kb)

```

then i open up browser and click on the file download button and when i try to open it is is corrupted. I tried doing same with image but image is displayed correctly.  
Have i missed anything please help.  
Thanks
