1 | import * as wmill from "https://deno.land/x/windmill@v1.47.3/mod.ts"; |
2 |
|
3 | export async function main( |
4 | webdav_res: wmill.Resource<"webdav">, |
5 | filePath: string, |
6 | data: string, |
7 | ) { |
8 | const resp = await fetch( |
9 | `${webdav_res.baseUrl}${filePath}`, |
10 | { |
11 | headers: { |
12 | "Authorization": "Basic " + |
13 | btoa(webdav_res.user + ":" + webdav_res.password), |
14 | }, |
15 | method: "PUT", |
16 | body: Uint8Array.from(atob(data), c => c.charCodeAt(0)), |
17 | }, |
18 | ); |
19 |
|
20 | return { |
21 | ok: resp.ok, |
22 | status: resp.status, |
23 | text: await resp.text(), |
24 | }; |
25 | } |
26 |
|