Browse Source

Cleanup "blob:" url when file is stopped.

pull/81/head
Joachim Bauch 11 years ago
parent
commit
25504a0a4b
  1. 16
      static/js/services/filedata.js

16
static/js/services/filedata.js

@ -54,10 +54,22 @@ define(["jquery", "underscore", "sha", "webrtc.adapter"], function($, _, jsSHA) @@ -54,10 +54,22 @@ define(["jquery", "underscore", "sha", "webrtc.adapter"], function($, _, jsSHA)
var data = new Blob(dataBuffer, {
type: this.owner.info.type || "application/octet-stream"
});
var url = null;
this.file = {
toURL: function() {
// TODO: only create once and revoke URL when no longer needed
return URL.createObjectURL(data);
if (!url) {
url = URL.createObjectURL(data);
}
return url;
},
remove: function(callback) {
if (url) {
URL.revokeObjectURL(url);
url = null;
}
if (callback) {
callback();
}
}
}
this.owner.file = this.file;

Loading…
Cancel
Save