Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #32023
| From | Richard Maher <maher_rjSPAMLESS@hotmail.com> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Display SQL Server Blob |
| Date | 2016-12-29 14:18 +0800 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <o429rn$156l$2@gioia.aioe.org> (permalink) |
| References | <58e2ece9-ec59-4e3f-b3ec-601ba0012bce@googlegroups.com> |
On 29-Dec-16 3:01 AM, minevillian.gmac@gmail.com wrote:
> Hi. We have a Microsoft Access application that we are migrating to a
> web based application. There are a few Blob fields in the backend
> SQL/Server database that we want to display on the web page. The
> Blob's can be either PDF, JPG, MSG, etc. format. We are having
> trouble displaying the blob data being returned. We are not sure of
> the syntax for displaying blob data in an IMG tag (ie. does the blob
> data have to be converted first.) The following gives me an
> ERR_INVALID_URL error:
>
> <img src="data:image/jpeg;base64,' + $(this).data("Blob") + '">
>
> Any help appreciated.
>
> Thanks. Grant.
>
First rule of Javascript: Don't use shitty libraries
Second rule of Javascript: STOP using shitty libraries
Third rule of Javascript: It's a great language and almost everything is
easy. Something like: -
function loadPhoto(outputType)
{
var xmlhttp = Tier3Toolbox.getXHR();
xmlhttp.open('GET', PHOTO_URL, true);
xmlhttp.responseType = 'blob';
if (outputType == 0){
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4) {
if (xmlhttp.status == 200) {
var blob = xmlhttp.response;
photoImg.src = window.URL.createObjectURL(blob);
setTimeout(setOnCampusImage,0);
} else {
photoImg.src = 'unknown.png';
}
}
}
} else {
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4) {
if (xmlhttp.status == 200) {
var blob = xmlhttp.response;
photoImg.src = window.URL.createObjectURL(blob);
} else {
photoImg.src = 'unknown.png';
}
personaScreen1.style.visibility="hidden";
personaScreen1.style.zIndex=-1;
personaScreen2.style.visibility="visible";
personaScreen2.style.zIndex=5;
activeScreen = personaScreen2;
logonConfirmOK.focus();
params.currUser = username.value;
updateStorage(0);
}
}
};
xmlhttp.send();
}
PHOTO_URL points at: -
[AcceptVerbs(HttpVerbs.Post | HttpVerbs.Get)]
public ActionResult getPhoto()
{
if (Session[SESSIONUSER] == null)
{
Response.StatusCode = 401;
Response.StatusDescription = "You are not authorized for
access.";
HttpContext.ApplicationInstance.CompleteRequest();
return null;
}
SessionUser sessionUser = (SessionUser)Session[SESSIONUSER];
return base.File(getImagePath(sessionUser.userId),
"image/jpeg");
}
OK it's not a blob but that's not the issue is it?
Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar | Unroll thread
Display SQL Server Blob minevillian.gmac@gmail.com - 2016-12-28 11:01 -0800
Re: Display SQL Server Blob Grant MacDonald <minevillian.gmac@gmail.com> - 2016-12-29 03:48 -0800
Re: Display SQL Server Blob Luuk <luuk@invalid.lan> - 2016-12-28 20:16 +0100
Re: Display SQL Server Blob Grant MacDonald <minevillian.gmac@gmail.com> - 2016-12-29 03:43 -0800
Re: Display SQL Server Blob Richard Maher <maher_rjSPAMLESS@hotmail.com> - 2016-12-29 14:18 +0800
csiph-web