"Murphy was an optimist!"
Do you store images in a database? July 11, 2008 11:15 amPosted by Doug McCaughan in : .NET, ASP, c#, MS SQL, MySQL, Programming, Technology
As I have built PHP and ColdFusion applications over the years, I have had to deal with image and file uploading from the application. Browsers were not designed for moving files from a client to a server; specifically, browsers were designed to receive files from a server to a client. To move files from a client to a server, an FTP program is used. (My favorite FTP client is WinSCP.) Now, a form can be written and used to upload a picture, movie, or other file from the client (you) to the server. You probably do this quite frequently with Flickr, Youtube and so forth. It is convenient from the enduser point of view because it removes the need to learn new software (the ftp client) and prevents having to get an administrator to create a username and password for each user on the server. Plus, by managing the files through the web application instead of the FTP program, you can programmatically control what is being allowed onto the server so that your user doesn’t maliciously upload an executable designed to damage the server rather than that family vacation photograph.
As a programmer, I have to make decisions about where to store these uploaded files. A common approach is to have a directory on the webserver which cannot be accessed by a browser (that is, the only way to get to the file is through the programming). The filename is then stored in the database. As an independent consultant, I work with different programmers/designers with varied skillsets and differing philosophies on coding. Some coders, like Eric Wise, actually prefer to store the files in the database itself. Eric claims:
…this is pretty sloppy and difficult to manage especially if for some reason you want to reorganize the data… [Source, Eric Wise, Images, Thumbnails, SQL Server, and ASP .NET – Level 200]
Eric describes a process of storing images in SQL Server 2005, automatically compressing the images, and generating thumbnails using ASP .NET. THis is interesting to me as I am wanting to learn C# to add to my skillsets.
I am concerned about database size and performance decreased caused by storing images/files in a database rather than storing the file in a directory and only storing the filename in the database. Jeffrey Palermo, a commenter on Eric Wise’s post, expresses the same concern:
Jeffrey Palermo said:
I’ve considered doing a photo album this way, but the main drawback is the size it makes the database. I have about 4GB of images. Do I really want that much in my database just for images. That also makes the bandwidth between web and db server highly used. Perhaps it’s no big deal, but to date I’ve kept my photos on the web server. Please post if you find no issues with the size of the data in the database when you have _lots_ of pictures there.
And Eric responds:
Eric Wise said:
With the compression tool I referenced, the original image shown was over 2MB, now it’s 165KB.
Having many large files would definately cause a performance issue, but with compression and the fact that it will probably be rare to have more than 2-3 pictures of an asset I’m not all that concerned about it.
What is your approach to storing images from a web application? See also.4comments
The ASP Butt Kicking Saga September 22, 2007 10:48 pmPosted by Doug McCaughan in : ASP, Daily Life, Programming, Technology
Hurdle 2 is now complete! The host’s local SMTP server is not configured correctly. The website is hosting its pop/smtp email else where. Using Method 3 of Sending email using CDOSYS ( THE REAL DEAL ) I was able to finally get email to send!
Method 3 ( Using remote mail server )
<% Dim ObjSendMail Set ObjSendMail = CreateObject("CDO.Message") 'This section provides the configuration information for the remote SMTP server. ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'Send the message using the network (SMTP over the network). ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="mail.yoursite.com" ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False 'Use SSL for the connection (True or False) ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60 ' If your server requires outgoing authentication uncomment the lines bleow and use a valid email address and password. 'ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'basic (clear-text) authentication 'ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") ="firstname.lastname@example.org" 'ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="yourpassword" ObjSendMail.Configuration.Fields.Update 'End remote SMTP server configuration section== ObjSendMail.To = "email@example.com" ObjSendMail.Subject = "this is the subject" ObjSendMail.From = "firstname.lastname@example.org" ' we are sending a text email.. simply switch the comments around to send an html email instead 'ObjSendMail.HTMLBody = "this is the body" ObjSendMail.TextBody = "this is the body" ObjSendMail.Send Set ObjSendMail = Nothing %>
In addition to what you see here there are plenty of properties you can add to these examples.
Here are a few examples.
ObjSendMail.CC = “email@example.com”
Blind Carbon Copy
ObjSendMail.BCC = “firstname.lastname@example.org”
Send Attachment (we hard code it here, but you could specify the file path using Server.Mappath as well)
and a ton of other things you can do…
Pages I found useful during this hurdle:
- CDOSYS or CDONTS, Which Will It Be?
- Send via ASP Page w CDONTS – Mail Stuck In SMTP Queue – Please help!
- Localhost mail stuck in QUEUE
- Mail Stuck in Queue Folder – IIS SMTP Virtual Server – Windows XP Service Pack 2 This one advised adding two crlf’s to the end of email.
See also Microsoft’s CDOSYS Documentation.
The final hurdle is rewriting their document management system. Presently, they have an admin piece that uploads documents to a single directory. The documents are then accessible to their customers. They want the ability to classify those documents. The approach will be to allow the documents to live in subdirectories representing the categories. This should be interesting.1 comment so far
Yesterday’s Butt Kicking Continues September 22, 2007 7:08 amPosted by Doug McCaughan in : ASP, Daily Life, Programming, Technology
Yesterday’s morning R&D centered around trouble shooting an SMTP problem with a Windows2003 server and ASP. Basically, I don’t get the error on my development server, which is still a Windows2000 machine. That means it could be code or server setup. The problem manifests itself when an attempt is made to send an email after a form is submitted.
CDO.Message.1 error ‘80040220’
The “SendUsing” configuration value is invalid.
I solve this in the next 2 hours!
Update: Why does Google continue to index www.experts-exchange.com?! Never click anything that is a link to www.experts-exchange.com! They obviously understand SEO really well.
Update: Troubleshooting thus far.
- Contacted the web host and explained that I think the server is not configured correct since emailing through telnet seemed to fail (but I might have done something wrong). Tech support explained that although they host the website that another company hosts the email. Excuse me? And that has exactly what to do with sending an email from asp through localhost? Here’s another testing through telnet instructional.
- Wow! SMTPDiag is fantastic. I’ve used it before but sort of put it out of my mind until now. It returns "failed to connect to the domain controller Error: ‘8007054b"
- How to test outbound mail flow with a file in the Pickup folder
- Initially looked like ColdFusion could send from the domain that ASP could not then I realized someone has changed cfmail to use an external mail server. Wonder how I would do that with ASP.
- After reading "SendUsing" configuration value is invalid (80040220), and access privilege problems caused by Exchange 2000 SP3, and how to test the SMTP service, and Troubleshooting email, the telnet way, and Troubleshooting IIS SMTP, and Testing email using RFC-822 and the pickup folder, I finally returned to reading all the comments in CDOSYS or CDONTS, Which Will It Be? to discover an astute comment by Scott Forsyth that this is indeed a permissions error and fixed by searching google for metaacl.vbs to discover these two technotes: ACLs and using MetaACL for metabase ACL permission changes (for understanding) and The MetaAcl tool for modifying metabase permissions on the IIS Admin Objects is available (for the vbs packaged within a self-extracting archive)
Title: The “SendUsing” configuration value is invalid in Windows 2003
Name: Scott Forsyth
Date: 3/27/2006 10:10:04 AM
On Windows Server 2003, if you don’t specify the default smtp server, it needs to obtain that from the IIS metabase. That isn’t allowed by default in IIS6, but you can add it with metaacl.vbs. Google and download a copy of metaacl.vbs and the run the following:
cscript metaacl.vbs “IIS://Localhost/smtpsvc” IIS_WPG RE
cscript metaacl.vbs “IIS://Localhost/smtpsvc/1” IIS_WPG RE
This will give the IIS_WPG group read permissions to the smtpsrv node so that you’ll be able to obtain the default SMTP server without specifically setting it in code. This will often resolve the error that you have run into.
Now, all of that said, only hurdle one has been jumped. My error message of "The "SendUsing" configuration value is invalid." is gone but mail is getting stuck in //Inetpub/mailroot/Queue. At least it is not going to the Badmail folder. Brief break then onto hurdle two.1 comment so far
Today’s Mystery Error Message September 21, 2007 8:28 amPosted by Doug McCaughan in : ASP, Programming, Technology
I have a little ASP application that works fine on my development server. On the production server I get:
CDO.Message.1 error ‘80040220’
The “SendUsing” configuration value is invalid.
These are the things that make web application development a bit maddening.1 comment so far
ASP Classic on Windows 2003? Jump a hoop! September 19, 2007 10:49 amPosted by Doug McCaughan in : ASP, Programming, Technology
If you are trying to get an Active Server Pages class (instead of .NET) application to work on your Windows 2003 and not getting any pages returned, look in the Internet Information Services (IIS) Manager at the Web Services Extensions. You are likely to see that Active Server Pages is Prohibited. Simply right click and choose Allow. Now your ASP classic application will function!add a comment