2

I'm trying to fetch an image stored at S3, via AJAX, which has been uploaded using InkFilePicker. InkFilePicker has a method called filepicker.read() which can be used to read the raw data from an image. However, it's quite limited so I want to use jQuery.ajax() instead. But it seems that they don't return exactly the same data.

The data received when using filepicker.read() looks like this when logging it to the console:

Data from filepicker.read()

When using jQuery.ajax() it looks like this:

Data from jQuery.ajax()

When using the data returned by jQuery.ajax() my other scripts seems to break (I'm extracting the EXIF data).

So, why does it look different at all? Does jQuery try to encode/decode the data somehow? Can I prevent that?

4
  • You want just asynchronously load image on DOM via AJAX? Commented Oct 20, 2013 at 10:43
  • @Max No. I just want to fetch the raw image data so I can process it (in this case, extract EXIF data). Commented Oct 20, 2013 at 11:44
  • For just getting EXIF, use the jQuery plugin Commented Oct 20, 2013 at 12:47
  • @Max, well I couldn't make it work when the image wasn't on the same server and inserted dynamically into the DOM. Instead I use this: github.com/mattiasw/ExifReader in combination with an ajax range request. Commented Oct 20, 2013 at 12:50

1 Answer 1

1

Ok, I had to add this to override the mimetype for some reason...

$.ajax({
...
  beforeSend: function(xhr) {
      xhr.overrideMimeType( "text/plain; charset=x-user-defined" )
  }
...
})
Sign up to request clarification or add additional context in comments.

1 Comment

Yes. At least it makes the rest of my scripts work without complaining about bad image data...

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.