Edits history of script submission #5971 for ' Load a preview of the file (windmill)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    /**
     * Load a preview of the file
     *
     */
    export async function main(
      workspace: string,
      file_key: string | undefined,
      file_size_in_bytes: string | undefined,
      file_mime_type: string | undefined,
      csv_separator: string | undefined,
      csv_has_header: string | undefined,
      read_bytes_from: string | undefined,
      read_bytes_length: string | undefined
    ) {
      const url = new URL(
        `${BASE_URL}/api/w/${workspace}/job_helpers/load_file_preview`
      );
      for (const [k, v] of [
        ["file_key", file_key],
        ["file_size_in_bytes", file_size_in_bytes],
        ["file_mime_type", file_mime_type],
        ["csv_separator", csv_separator],
        ["csv_has_header", csv_has_header],
        ["read_bytes_from", read_bytes_from],
        ["read_bytes_length", read_bytes_length],
      ]) {
        if (v !== undefined && v !== "") {
          url.searchParams.append(k, v);
        }
      }
      const response = await fetch(url, {
        method: "GET",
        headers: {
          Authorization: "Bearer " + WM_TOKEN,
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 370 days ago

  • nativets
    /**
     * Load a preview of the file
     *
     */
    export async function main(
      workspace: string,
      file_key: string | undefined,
      file_size_in_bytes: string | undefined,
      file_mime_type: string | undefined,
      csv_separator: string | undefined,
      csv_has_header: string | undefined,
      read_bytes_from: string | undefined,
      read_bytes_length: string | undefined
    ) {
      const url = new URL(
        `${BASE_URL}/api/w/${workspace}/job_helpers/load_file_preview`
      );
      for (const [k, v] of [
        ["file_key", file_key],
        ["file_size_in_bytes", file_size_in_bytes],
        ["file_mime_type", file_mime_type],
        ["csv_separator", csv_separator],
        ["csv_has_header", csv_has_header],
        ["read_bytes_from", read_bytes_from],
        ["read_bytes_length", read_bytes_length],
      ]) {
        if (v !== undefined && v !== "") {
          url.searchParams.append(k, v);
        }
      }
      const response = await fetch(url, {
        method: "GET",
        headers: {
          Authorization: "Bearer " + WM_TOKEN,
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 797 days ago