Skip to content

Commit 6f7e3fc

Browse files
authored
Create 5-thirdparty.md
1 parent 6024f01 commit 6f7e3fc

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

examples/docs/data/5-thirdparty.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
title: Third Party Integrations
3+
lang: en-US
4+
...
5+
6+
## Upload Thing
7+
8+
Bash stack works with [Upload Thing](https://uploadthing.com/). Here is some example code to get you started:
9+
10+
```bash
11+
# headers
12+
header Content-Type text/html
13+
end_headers
14+
source config.sh
15+
DATA="$(curl --request POST \
16+
--url https://uploadthing.com/api/uploadFiles \
17+
--header 'Content-Type: application/json' \
18+
--header "X-Uploadthing-Api-Key: $UPLOADTHING_SECRET" \
19+
--header 'X-Uploadthing-Version: 6.4.0' \
20+
--data '{ "files": [ { "name": "typing.gif", "size": 29634, "type": "", "customId": "" } ],
21+
"acl": "public-read", "metadata": null, "contentDisposition": "inline" }')"
22+
FILE_DATA="$(echo "$DATA" | jq -r '.data[0]')"
23+
cat <<EO2
24+
<script type="text/javascript">
25+
const presigned = ${FILE_DATA};
26+
async function handle(e) {
27+
const theFile = document.querySelector("#theFile").files[0];
28+
const formData = new FormData();
29+
Object.entries(presigned.fields).forEach(([k, v]) => formData.append(k, v));
30+
formData.append("file", theFile);
31+
const res = await window.fetch(presigned.url,
32+
{ method: "POST", body: formData, headers: new Headers({ Accept: "application/xml", }), });
33+
window.location = presigned.fileUrl;
34+
}
35+
document.addEventListener("DOMContentLoaded", (event) => {
36+
document.querySelector("input[type=file]").addEventListener('change', handle);
37+
});
38+
</script>
39+
<input id="theFile" name="file" type="file" style="width:100vw;height:100vh;"/>
40+
EO2
41+
```

0 commit comments

Comments
 (0)