File Upload issue

  • 1
  • Question
  • Updated 2 years ago
  • Answered
  • (Edited)
We are trying to get the base64 of an image we have uploaded by trying to get it from skuid.$M("model").data[0].Body.realBlobValue.asByteArray. With some images it works but with others the value is not there with the only field after skuid.$M("model").data[0].Body.realBlobValue being .file and it returns a value that looks like a filepath ": "/tmp/bvf/blob2885374293920319543.bvf". We would just like a little background on where to go or what to do so that we can consistently grab the base64 of the image that is uploaded
Photo of Spencer Ince

Spencer Ince

  • 90 Points 75 badge 2x thumb

Posted 2 years ago

  • 1
Photo of Matt Sones

Matt Sones, Champion

  • 32,106 Points 20k badge 2x thumb
Pablo has the answer:

A little adjustment, It seems that depending of the filetype the body object is different. so for HTML files the base64 is not in .realBlobValue.asByteArray  is in .asByteArray

var field = arguments[0];var value = arguments[1];
var Base64content;
var contenttype=field.row.ContentType;
var show="<iframe src=\"data:"+contenttype+";base64,"+Base64content+"\"></iframe>";
var iframe = $( '<iframe>' ).addClass('previewiframe').attr('src','data:'+contenttype+';base64,'+Base64content+'').appendTo(field.element.find('div'));
See the full thread here: