5/5/2019
Posted by 

Join GitHub today

GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.

Sign up New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comments

commented Jun 8, 2016
edited by jimmywarting

Hi!

I have following situation:

I call a servlet in javascript. The servlet returns a byte stream of a PDF file.

The file is downloaded but badly in a wrong encoding!
When i dowload the data in the servlet to a file its different to the file saved via your script. See attachments. How can this be done correctly?

viaFileSaverScript.pdf
fromServlet.pdf

Thanks!

commented Jun 8, 2016
edited

I have forgotten mostly all about jQuery. But you should fetch the data as a blob directly using xhrFields..

jquery is trying to download the data as plain text and encode it, you don't want that

commented Jun 8, 2016

Thanks for the fast reply!

Now i get

jquery-2.1.3.min.js?v=5.0.2.00.07:4 Uncaught InvalidStateError: Failed to read the 'responseText' property from 'XMLHttpRequest': The value is only accessible if the object's 'responseType' is ' or 'text' (was 'blob').

commented Jun 8, 2016
edited

Made it now with help of
http://stackoverflow.com/questions/29023509/handling-error-messages-when-retrieving-a-blob-via-ajax

commented Jun 8, 2016
edited

Good, i was going to say that most stackoverflow answer and articles refer to using plain xhr, as jquery don't have support for responseType yet Best apk downloader windows 10 1.

However, I found this transport that adds responseType support to jquery's ajax
http://www.henryalgus.com/reading-binary-files-using-jquery-ajax/

commented Jun 8, 2016

Another solution is to use the new ajax api: fetch

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Join GitHub today

GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.

Sign up New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails. Hum saath saath full movie youtube.

Already on GitHub? Sign in to your account

Comments

commented Nov 16, 2015

consider the following code:

I thought shelf would return a response with content-type: application/atom+xml; charset=utf-8

but I get this:

content-type: application/octet-stream; charset=utf-8

After digging down in shelf code, it seems that the _adjustHeaders function doesn't compare headers names case insensitively.

Is that an intended behavior? If not, would you accept a PR fixing this?

commented Nov 16, 2015

I opened a PR with a possible fix #53

added a commit to Pacane/shelf that referenced this issue Nov 16, 2015

Fixed comparison case for content-type header

closed this in decce6bNov 18, 2015

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment