How to use the @esri/solution-common.blobToText function in @esri/solution-common

To help you get started, we’ve selected a few @esri/solution-common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Esri / solution.js / packages / creator / examples / createSolutionFromItem / lib / getItemInfo.ts View on Github external
resolve("<i>none</i>");
      return;
    }
    const file = blob as File;

    if (blob.type === "application/json") {
      solutionCommon.blobToJson(blob).then(
        text =&gt; resolve(textAreaHtml(JSON.stringify(text, null, 2))),
        error =&gt; resolve("<i>problem extracting JSON: " + error + "</i>")
      );
    } else if (
      blob.type.startsWith("text/plain") ||
      blob.type === "text/xml" ||
      blob.type === "application/xml"
    ) {
      solutionCommon.blobToText(blob).then(
        text =&gt; resolve(textAreaHtml(text)),
        error =&gt; resolve("<i>problem extracting text: " + error + "</i>")
      );
    } else if (blob.type.startsWith("image/")) {
      let html =
        '<img style="max-width:256px;border:1px solid lightgray;" src="' +
        window.URL.createObjectURL(blob) +
        '">';
      if (file.name) {
        html +=
          '&nbsp;&nbsp;&nbsp;&nbsp;<a download="' +
          file.name +
          '" href="' +
          window.URL.createObjectURL(file) +
          '">' +
          file.name +</a>
github Esri / solution.js / packages / common / examples / getItemInfo / src / main.ts View on Github external
resolve("<i>none</i>");
      return;
    }
    const file = blob as File;

    if (blob.type === "application/json") {
      common.blobToJson(blob).then(
        text =&gt; resolve(textAreaHtml(JSON.stringify(text, null, 2))),
        error =&gt; resolve("<i>problem extracting JSON: " + error + "</i>")
      );
    } else if (
      blob.type.startsWith("text/plain") ||
      blob.type === "text/xml" ||
      blob.type === "application/xml"
    ) {
      common.blobToText(blob).then(
        text =&gt; resolve(textAreaHtml(text)),
        error =&gt; resolve("<i>problem extracting text: " + error + "</i>")
      );
    } else if (blob.type.startsWith("image/")) {
      let html =
        '<img style="max-width:256px;border:1px solid lightgray;" src="' +
        window.URL.createObjectURL(blob) +
        '">';
      if (file.name) {
        html +=
          '&nbsp;&nbsp;&nbsp;&nbsp;<a download="' +
          file.name +
          '" href="' +
          window.URL.createObjectURL(file) +
          '">' +
          file.name +</a>