Thanks. I appreciate the suggestions. Unfortunately, I can't store the metadata in a separate data field. I wish I could, but the application requires that the data elements be very atomic. You see, this is for an inventory tracking application for my work, and the databases are designed to be very extendable and adaptable to the specific needs of the individual departments. There are several, I guess you could call them 'abstracted' types (ie. short text, long text, url, file, single-select list, multiple-select list, etc) and each of the data elements in the inventory has one of these types associated with it. Each of those types is associated (in another table) with a MySQL type. This way, we can build the scripting so that the database administrators can add or delete fields easily, and the different abstracted types can be treated differently in the scripting. For example, both a url and a short text could be stored as a varchar, but the way the script presents a short text in the web interface is with a simple text box, while a url is presented with a link, and a text box. This is of course a simple example, but illustrates the idea.

Anyway, the short answer is that every abstract type needs to be associated with only one MySQL type, and the stored file still needs to include the filename, and, if available the mime type.

So, just 'cause I'm curious, is there a performance advantage to using the regexp to remove the metadata header, rather than just extracting the data by using the regexp backreference? I suppose, since a 'file' is being stored as a mediumblob (max about 16 MB) that it could be a lot of data to run through the regexp engine. Hmm. I'll have to think about that.

Thanks again,

Lloyd

Mac Newbold wrote:

Today at 4:12pm, Lloyd T Brown said:



Here's the situation.  I'm encoding files (base 64 encoding) to put them
into a database.  I want to also include some metadata with the encoded
string, namely filename and mime type.  Here's an example of the format
I decided to use.

"filename: somefilename.txt;mime-type: text/plain; data:
VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw=="



I know you're really asking for a regexp, but if I may, I'd like to suggest you [re]consider having the meta data be stored as a separate column in the table. This could have several benefits:

1) Don't have to parse it out of a blob/text field
2) Can use the meta data for db queries (i.e. selecting by name/type, etc.)
3) Simpler code to read and write file entries in the database
4) More flexible: much easier to expand your meta-data set later
5) That's what databases are for

But of course I don't know the entire situation, so this may not be
appropriate in your setting.

BTW, the regexp looked pretty good, and I pretty much agree with what
Jacob Fugal said.

Thanks,
Mac

--
Mac Newbold             MNE - Mac Newbold Enterprises, LLC
[EMAIL PROTECTED]       http://www.macnewbold.com/

____________________
BYU Unix Users Group http://uug.byu.edu/ ___________________________________________________________________
List Info: http://uug.byu.edu/cgi-bin/mailman/listinfo/uug-list






--

--------------------
"Open Source is not a crime."
               -Seen on a bumper sticker
--------------------



____________________
BYU Unix Users Group http://uug.byu.edu/ ___________________________________________________________________
List Info: http://uug.byu.edu/cgi-bin/mailman/listinfo/uug-list

Reply via email to