How to use the @esri/solution-common.blobToJson 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 / common / examples / getItemInfo / src / main.ts View on Github external
return new Promise(resolve => {
    if (!blob || blob.size === 0) {
      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 =
        '
github Esri / solution.js / packages / creator / examples / createSolutionFromItem / lib / getItemInfo.ts View on Github external
return new Promise(resolve =&gt; {
    if (!blob || blob.size === 0) {
      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 =
        '