no more blob conversions
This commit is contained in:
119
dist/swagger-ui.js
vendored
119
dist/swagger-ui.js
vendored
File diff suppressed because one or more lines are too long
24
dist/swagger-ui.min.js
vendored
24
dist/swagger-ui.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -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));
|
||||||
|
|||||||
Reference in New Issue
Block a user