# How to upload a file via API and get it's URL?

**URL:** https://meta.discourse.org/t/how-to-upload-a-file-via-api-and-get-its-url/123732
**Category:** Development
**Tags:** rest-api
**Created:** [7월 23, 2019, 1:50오후 UTC](https://meta.discourse.org/t/how-to-upload-a-file-via-api-and-get-its-url/123732 "2019-07-23T13:50:39Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![darkster](https://avatars.discourse-cdn.com/v4/letter/d/258eb7/32.png) [@darkster](https://meta.discourse.org/u/darkster)
#### Post date: [7월 23, 2019, 1:50오후 UTC](https://meta.discourse.org/t/how-to-upload-a-file-via-api-and-get-its-url/123732/1 "2019-07-23T13:50:39Z")

</div>

Hello, I want to upload a file(not an image) via the API and get the URL back. How can I accomplish this?  
I tried the solution provided here: [https://meta.discourse.org/t/using-the-discourse-api-to-post-with-uploaded-files/29833/23](https://meta.discourse.org/t/using-the-discourse-api-to-post-with-uploaded-files/29833/23) but it seems that it is no longer up to date.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [7월 23, 2019, 2:01오후 UTC](https://meta.discourse.org/t/how-to-upload-a-file-via-api-and-get-its-url/123732/2 "2019-07-23T14:01:49Z")

</div>

See [Reverse engineer the Discourse API](https://meta.discourse.org/t/how-to-reverse-engineer-the-discourse-api/20576)

---

<div class="post-metadata">

### Author: ![Daniil\_Bazhenov](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/daniil_bazhenov/32/201247_2.png) [@Daniil\_Bazhenov](https://meta.discourse.org/u/Daniil_Bazhenov)
#### Post date: [1월 1, 2021, 5:33오후 UTC](https://meta.discourse.org/t/how-to-upload-a-file-via-api-and-get-its-url/123732/3 "2021-01-01T17:33:42Z")

</div>

이 질문에도 관심이 있습니다.  
API를 통해 파일 업로드를 지원하지 않는 것 같습니다.  
누군가 방법을 제안해 주실 수 있을까요?

UPD:  
해결했습니다. 문서에 해당 방법이 설명되어 있으며 정상적으로 작동합니다.

1. "/uploads.json"을 사용하여 파일을 업로드합니다. 응답으로 업로드된 파일의 Short URL을 받게 되며, 예: “upload://ueNyWDEgHhXIuIdB472fy9T6.txt”
2. 두 번째 API 요청으로 게시물을 업데이트합니다. post[raw]의 맨 끝에 다음과 같은 줄을 추가합니다:  
`[filename.txt|attachment](upload://ueNyWlEgHhXIuIdB472fy9T6.txt) (1.83 KB)`

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [1월 31, 2021, 5:33오후 UTC](https://meta.discourse.org/t/how-to-upload-a-file-via-api-and-get-its-url/123732/4 "2021-01-31T17:33:47Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
