Edits history of script submission #11416 for ' Nextcloud WebDAV: Get the content of a file (nextcloud)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    import axios from "axios";
    
    export async function main(
      nextcloud: RT.Nextcloud,
      path: string,
    ) {
    
      const res = await axios.get(
        `${nextcloud.baseUrl}/remote.php/dav/files/${nextcloud.userId}/${path}`,
        {
          auth: {
            username: nextcloud.userId,
            password: nextcloud.token,
          },
        },
      );
      if (res.status !== 200) {
        throw new Error(res.statusText)
      }
      return res.data
    }

    Submitted by nextcloud 86 days ago

  • bun
    import * as wmill from "windmill-client";
    import axios from "axios";
    
    type Nextcloud = {
      baseUrl: string,
      password: string,
      username: string
    };
    
    export async function main(
      ncResource: Nextcloud,
      userId: string | null = null,
      path: string,
      useAppApiAuth: boolean = false,
    ) {
    
      const res = await axios.get(
        `${ncResource.baseUrl}/remote.php/dav/files/${userId || ncResource.username}/${path}`,
        {
          auth: {
            username: userId || ncResource.username,
            password: ncResource.password,
          },
          ...(useAppApiAuth && ({
            headers: {
              "AA-VERSION": ncResource.aa_version,
              "EX-APP-ID": ncResource.app_id,
              "EX-APP-VERSION": ncResource.app_version,
              "AUTHORIZATION-APP-API": btoa(
                `${userId || ncResource.username}:${ncResource.password}`,
              ),
            },
          })),
        },
      );
      if (res.status !== 200) {
        throw new Error(res.statusText)
      }
      return res.data
    }

    Submitted by nextcloud 475 days ago

  • bun
    import * as wmill from "windmill-client";
    import axios from "axios";
    
    type Nextcloud = {
      baseUrl: string,
      password: string,
      username: string
    };
    
    export async function main(
      ncResource: Nextcloud,
      userId: string | null = null,
      path: string,
      useAppApiAuth: boolean = false,
    ) {
    
      const res = await axios.get(
        `${ncResource.baseUrl}/remote.php/dav/files/${userId || ncResource.username}/${path}`,
        {
          auth: {
            username: userId || ncResource.username,
            password: ncResource.password,
          },
          ...(useAppApiAuth && ({
            headers: {
              "AA-VERSION": "2.3.0",
              "EX-APP-ID": "flow",
              "EX-APP-VERSION": "1.0.0",
              "AUTHORIZATION-APP-API": btoa(
                `${userId || ncResource.username}:${ncResource.password}`,
              ),
            },
          })),
        },
      );
      if (res.status !== 200) {
        throw new Error(res.statusText)
      }
      return res.data
    }

    Submitted by nextcloud 485 days ago

  • bun
    import * as wmill from "windmill-client";
    import axios from "axios";
    
    type Nextcloud = {
      baseUrl: string,
      password: string,
      username: string
    };
    
    export async function main(
      ncResource: Nextcloud,
      userId: string | null = null,
      path: string,
      useAppApiAuth: boolean = false,
    ) {
    
      const res = await axios.get(
        `${ncResource.baseUrl}/remote.php/dav/files/${userId || ncResource.username}/${path}`,
        {
          auth: {
            username: userId || ncResource.username,
            password: ncResource.password,
          },
          ...(useAppApiAuth && ({
            headers: {
              "AA-VERSION": "2.3.0",
              "EX-APP-ID": "flow",
              "EX-APP-VERSION": "1.0.0",
              "AUTHORIZATION-APP-API": btoa(
                `${userId || ncResource.username}:${ncResource.password}`,
              ),
            },
          })),
        },
      );
      if (res.status !== 200) {
        throw new Error(res.statusText)
      }
      return res.data
    }

    Submitted by nextcloud 485 days ago

  • bun
    import * as wmill from "windmill-client@1";
    import axios from "axios";
    
    type Nextcloud = {
      baseUrl: string,
      password: string,
      username: string
    };
    
    export async function main(
      ncResource: Nextcloud,
      userId: string | null = null,
      path: string,
      useAppApiAuth: boolean = false,
    ) {
    
      const res = await axios.get(
        `${ncResource.baseUrl}/remote.php/dav/files/${userId || ncResource.username}/${path}`,
        {
          auth: {
            username: userId || ncResource.username,
            password: ncResource.password,
          },
          ...(useAppApiAuth && ({
            headers: {
              "AA-VERSION": "2.3.0",
              "EX-APP-ID": "flow",
              "EX-APP-VERSION": "1.0.0",
              "AUTHORIZATION-APP-API": btoa(
                `${userId || ncResource.username}:${ncResource.password}`,
              ),
            },
          })),
        },
      );
      if (res.status !== 200) {
        throw new Error(res.statusText)
      }
      return res.data
    }

    Submitted by rubenfiszel 485 days ago

  • bun
    import * as wmill from "windmill-client@1";
    import axios from "axios";
    
    type Nextcloud = {
      baseUrl: string,
      password: string,
      username: string
    };
    
    export async function main(
      ncResource: Nextcloud,
      userId: string | null = null,
      path: string,
      useAppApiAuth: boolean = false,
    ) {
    
      const res = await axios.get(
        `${ncResource.baseUrl}/remote.php/dav/files/${userId || ncResource.username}/${path}`,
        {
          auth: {
            username: userId || ncResource.username,
            password: ncResource.password,
          },
          ...(useAppApiAuth && ({
            headers: {
              "AA-VERSION": "2.3.0",
              "EX-APP-ID": "flow",
              "EX-APP-VERSION": "1.0.0",
              "AUTHORIZATION-APP-API": btoa(
                `${userId || ncResource.username}:${ncResource.password}`,
              ),
            },
          })),
        },
      );
      if (res.status !== 200) {
        throw new Error(res.statusText)
      }
      return res.data
    }

    Submitted by nextcloud 485 days ago

  • bun
    import * as wmill from "windmill-client@1";
    import axios from "axios";
    
    // fill the type, or use the +Resource type to get a type-safe reference to a resource
    // type Postgresql = object
    
    export async function main(
      ncResource: Nextcloud,
      userId: string | null = null,
      path: string,
      useAppApiAuth: boolean = false,
    ) {
    
      const res = await axios.get(
        `${ncResource.baseUrl}/remote.php/dav/files/${userId || ncResource.username}/${path}`,
        {
          auth: {
            username: userId || ncResource.username,
            password: ncResource.password,
          },
          ...(useAppApiAuth && ({
            headers: {
              "AA-VERSION": "2.3.0",
              "EX-APP-ID": "flow",
              "EX-APP-VERSION": "1.0.0",
              "AUTHORIZATION-APP-API": btoa(
                `${userId || ncResource.username}:${ncResource.password}`,
              ),
            },
          })),
        },
      );
      if (res.status !== 200) {
        throw new Error(res.statusText)
      }
      return res.data
    }

    Submitted by nextcloud 486 days ago

  • bun
    import * as wmill from "windmill-client@1";
    import axios from "axios";
    
    // fill the type, or use the +Resource type to get a type-safe reference to a resource
    // type Postgresql = object
    
    export async function main(
      nextcloudResource: string,
      userId: string | null = null,
      path: string,
      useAppApiAuth: boolean = false,
    ) {
      const ncResource = await wmill.getResource(
        nextcloudResource,
      );
      const res = await axios.get(
        `${ncResource.baseUrl}/remote.php/dav/files/${userId || ncResource.username}/${path}`,
        {
          auth: {
            username: userId || ncResource.username,
            password: ncResource.password,
          },
          ...(useAppApiAuth && ({
            headers: {
              "AA-VERSION": "2.3.0",
              "EX-APP-ID": "flow",
              "EX-APP-VERSION": "1.0.0",
              "AUTHORIZATION-APP-API": btoa(
                `${userId || ncResource.username}:${ncResource.password}`,
              ),
            },
          })),
        },
      );
      if (res.status !== 200) {
        throw new Error(res.statusText)
      }
      return res.data
    }

    Submitted by nextcloud 491 days ago