Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #32013 > unrolled thread

Display SQL Server Blob

Started byminevillian.gmac@gmail.com
First post2016-12-28 11:01 -0800
Last post2016-12-29 14:18 +0800
Articles 5 — 4 participants

Back to article view | Back to comp.lang.javascript


Contents

  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

#32013 — Display SQL Server Blob

Fromminevillian.gmac@gmail.com
Date2016-12-28 11:01 -0800
SubjectDisplay SQL Server Blob
Message-ID<58e2ece9-ec59-4e3f-b3ec-601ba0012bce@googlegroups.com>
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.

[toc] | [next] | [standalone]


#32014

FromGrant MacDonald <minevillian.gmac@gmail.com>
Date2016-12-29 03:48 -0800
Message-ID<9f5ebb0f-f327-4672-8cee-7fb7fd6dd8d4@googlegroups.com>
In reply to#32013
On Thursday, December 29, 2016 at 2:18:36 AM UTC-4, Richard Maher wrote:

> 
> 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?

Thanks Richard, I'll take a closer look at this.  The data is raw Blob data in several different formats (could be PNG, MSG, PDF, etc.)  I am passing it to the application in a JSON object which includes several other data items.

[toc] | [prev] | [next] | [standalone]


#32019

FromLuuk <luuk@invalid.lan>
Date2016-12-28 20:16 +0100
Message-ID<58640f81$0$21460$e4fe514c@news.xs4all.nl>
In reply to#32013
On 28-12-16 20:01, 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") + '">
...................................^..........................^

single quotes?

But, as the tag says IMG, it will only display images (PNG, JPG, BMP)
and not thing like PDF

>
> Any help appreciated.
>
> Thanks. Grant.
>

[toc] | [prev] | [next] | [standalone]


#32033

FromGrant MacDonald <minevillian.gmac@gmail.com>
Date2016-12-29 03:43 -0800
Message-ID<35e2653b-b9f5-41ed-b0fb-9fe4f86755c2@googlegroups.com>
In reply to#32019
Sorry, my copy from the source code to this post is missing the single quote before the <img

Yes, the img won't work with the PDF blobs or the MSG blobs...Microsoft Access must have built in libraries to handle that easily.  

On Wednesday, December 28, 2016 at 3:16:26 PM UTC-4, Luuk wrote:

> > <img src="data:image/jpeg;base64,' + $(this).data("Blob") + '">
> ...................................^..........................^
> 
> single quotes?
> 
> But, as the tag says IMG, it will only display images (PNG, JPG, BMP)
> and not thing like PDF
> 
> >
> > Any help appreciated.
> >
> > Thanks. Grant.
> >

[toc] | [prev] | [next] | [standalone]


#32023

FromRichard Maher <maher_rjSPAMLESS@hotmail.com>
Date2016-12-29 14:18 +0800
Message-ID<o429rn$156l$2@gioia.aioe.org>
In reply to#32013
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?

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web