separate download url from preview url

This commit is contained in:
or-else
2018-06-06 16:41:16 +03:00
parent 9c507ba631
commit 499bf1ee14
3 changed files with 18 additions and 6 deletions
+15 -3
View File
@@ -129,7 +129,8 @@ Sample JSON representation of the text above:
},
IM: {
open: function(data) {
var previewUrl = data.val ? base64toObjectUrl(data.val, data.mime) : data.ref;
// Don't use data.ref for preview: it's a security risk.
var previewUrl = base64toObjectUrl(data.val, data.mime);
var downloadUrl = data.ref ? data.ref : previewUrl;
var res = (data.name ? '<a href="' + downloadUrl + '" download="' + data.name + '">' : '') +
'<img src="' + previewUrl + '"' +
@@ -737,11 +738,22 @@ Sample JSON representation of the text above:
},
/**
* Get blob URL for a given entity.
* Given the entity, get URL which can be used for downloading
* entity data.
*
* @param {Object} entity to get the URl from.
*/
getBlobUrl: function(entity) {
getDownloadUrl: function(entity) {
return entity.ref ? entity.ref : base64toObjectUrl(entity.val, entity.mime);
},
/**
* Given the entity, get URL which can be used for previewing
* the entity.
*
* @param {Object} entity to get the URl from.
*/
getPreviewUrl: function(entity) {
return base64toObjectUrl(entity.val, entity.mime);
},