Edits history of script submission #166 for ' Upload File (webdav)'

  • deno
    import * as wmill from "https://deno.land/x/[email protected]/mod.ts";
    
    export async function main(
        webdav_res: wmill.Resource<"webdav">,
        filePath: string,
        data: string,
    ) {
        const resp = await fetch(
            `${webdav_res.baseUrl}${filePath}`,
            {
                headers: {
                    "Authorization": "Basic " +
                        btoa(webdav_res.user + ":" + webdav_res.password),
                },
                method: "PUT",
                body: Uint8Array.from(atob(data), c => c.charCodeAt(0)),
            },
        );
    
        return {
            ok: resp.ok,
            status: resp.status,
            text: await resp.text(),
        };
    }
    

    Submitted by jaller94 1301 days ago

  • deno
    import * as wmill from "https://deno.land/x/[email protected]/mod.ts";
    
    export async function main(
      webdav_res: wmill.Resource<"c_webdav">,
      filePath: string,
      data: string,
    ) {
      const resp = await fetch(
        `${webdav_res.baseUrl}${filePath}`,
        {
          headers: {
            "Authorization": "Basic " +
              btoa(webdav_res.user + ":" + webdav_res.password),
          },
          method: "PUT",
          body: Uint8Array.from(atob(data), c => c.charCodeAt(0)),
        },
      );
    
      return {
        ok: resp.ok,
        status: resp.status,
        text: await resp.text(),
      };
    }
    

    Submitted by jaller94 1347 days ago

  • deno
    import * as wmill from "https://deno.land/x/[email protected]/mod.ts";
    
    export async function main(
      webdav_res: wmill.Resource<"c_webdav">,
      filePath: string,
      data: string,
    ) {
      const resp = await fetch(
        // This might be specific to Nextcloud
        `${webdav_res.baseUrl}/dav/files/${webdav_res.user}/${filePath}`,
        {
          headers: {
            "Authorization": "Basic " +
              btoa(webdav_res.user + ":" + webdav_res.password),
          },
          method: "PUT",
          body: Uint8Array.from(atob(data), c => c.charCodeAt(0)),
        },
      );
    
      return {
        ok: resp.ok,
        status: resp.status,
        text: await resp.text(),
      };
    }
    

    Submitted by jaller94 1347 days ago