no more blob conversions

This commit is contained in:
Tony Tam
2016-09-15 10:35:01 -07:00
parent 4bdaeba797
commit 80e548df0a
3 changed files with 85 additions and 73 deletions

109
dist/swagger-ui.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -695,10 +695,9 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
if ('Blob' in window) { if ('Blob' in window) {
var type = contentType || 'text/html'; var type = contentType || 'text/html';
blob = new Blob([content], {type: type});
var a = document.createElement('a'); var a = document.createElement('a');
var href = window.URL.createObjectURL(blob); var href = window.URL.createObjectURL(content);
var fileName = response.url.substr(response.url.lastIndexOf('/') + 1); var fileName = response.url.substr(response.url.lastIndexOf('/') + 1);
var download = [type, fileName, href].join(':'); var download = [type, fileName, href].join(':');
@@ -746,16 +745,10 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
// Image // Image
} else if (/^image\//.test(contentType)) { } else if (/^image\//.test(contentType)) {
//pre = $('<img>').attr('src', url); var urlCreator = window.URL || window.webkitURL;
var imageUrl = urlCreator.createObjectURL(content);
var binary = ''; pre = $('<img>').attr( 'src', imageUrl);
var bytes = new Uint8Array( content );
var len = bytes.byteLength;
for (var i = 0; i < len; i++) {
binary += String.fromCharCode( bytes[ i ] );
}
pre = $('<img>').attr( 'src', 'data:' + contentType + ';base64,' + btoa(binary));
// Audio // Audio
} else if (/^audio\//.test(contentType) && supportsAudioPlayback(contentType)) { } else if (/^audio\//.test(contentType) && supportsAudioPlayback(contentType)) {
pre = $('<audio controls>').append($('<source>').attr('src', url).attr('type', contentType)); pre = $('<audio controls>').append($('<source>').attr('src', url).attr('type', contentType));