Preparing for github file persistence
This commit is contained in:
@ -7,8 +7,21 @@ export default function MediaProxy(value, file, uploaded = false) {
|
||||
this.value = value;
|
||||
this.file = file;
|
||||
this.uploaded = uploaded;
|
||||
this.uri = config.media_folder && !uploaded ? config.media_folder + '/' + value : value;
|
||||
this.toString = function() {
|
||||
return this.uploaded ? this.uri : window.URL.createObjectURL(this.file, { oneTimeOnly: true });
|
||||
};
|
||||
this.sha = null;
|
||||
this.path = config.media_folder && !uploaded ? config.media_folder + '/' + value : value;
|
||||
}
|
||||
|
||||
MediaProxy.prototype.toString = function() {
|
||||
return this.uploaded ? this.path : window.URL.createObjectURL(this.file, { oneTimeOnly: true });
|
||||
};
|
||||
|
||||
MediaProxy.prototype.toBase64 = function() {
|
||||
return new Promise((resolve, reject) => {
|
||||
const fr = new FileReader();
|
||||
fr.onload = (readerEvt) => {
|
||||
const binaryString = readerEvt.target.result;
|
||||
resolve(btoa(binaryString));
|
||||
};
|
||||
fr.readAsDataURL(this.file);
|
||||
});
|
||||
};
|
||||
|
Reference in New Issue
Block a user