0

I have published a query table that contains a BLOB field to ArcGIS REST and have not been able to access the images. I tried using esriRequest, but the response type that returns is text, and I think it should be image. I don't know if this is because there is something about the files the REST service doesn't like, or if I am missing something in the code. The images are currently being served out using PHP the query the SQL database. Here is the code I am trying to use to get the images:

var imageUrl = "https://ocean.floridamarine.org/arcgis/rest/services/.../MapServer/1/7";
    var params = {
        url: imageUrl,
        handleAs: "blob"
    }
    console.log("request params ", params);
    var imageRequest = esriRequest(params);
    imageRequest.then(requestSucceeded, requestFailed);
    function requestSucceeded(response, io) {
        console.log("esriRequest response ", response);
        var reader = new FileReader();
        if (response.type == "image/png") {
          //if working with image data
          reader.readAsDataURL(response);
          console.log("image response ", response);
        } else {
          reader.readAsText(response);
          console.log("reader response ", reader.readAsText(response));
        }
    };
    function requestFailed(error, io) {
       temp = temp + "<br/><div  style='text-align:center;'><strong>No Image Available</strong></div>";
       console.log(error);
    }

The url points to this, but not sure if I should be seeing an image here: rest service endpoint

Here is a screenshot of the console: console

As you can see, the response type is text (should be seeing an image?)

What I am doing wrong? Is a better way to go about this?

3
  • 1
    Is this a Web AppBuilder app, or just straight Esri JavaScript?
    – KHibma
    Commented Jun 11, 2019 at 19:06
  • The app was created using Web AppBuilder version 2.12. The images are currently being accessed on the server side using php. I don't have any specific knowledge about how the images are being written to the sql database, but I know they are submitted by the public through a web form. I am thinking that this is either a compatibility issue with ArcGIS (since the images were not inserted into the database by ArcMap), or maybe I am using the wrong method to try and extract them.
    – GeoGene
    Commented Jun 12, 2019 at 17:56
  • Please use the edit button beneath your question to revise it with any requested clarifications or additional information that may help to attract a potential answerer..
    – PolyGeo
    Commented Dec 5, 2020 at 7:35

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.