I have an ASP.Net application that needs to display an image that is stored in a Filemaker Container field. My query statement looks like:
SELECT GetAs(Image, 'JPG') FROM UA_Item_Pictures WHERE "Stock Number" = 33989 AND ImageOrder = 1
According to the documentation: The possible file types (case sensitive) you can re开发者_Python百科trieve from a container field in a FileMaker database file are:
'EMBO' OLE container data
'PDF ' Portable Document Format
'EMF+' Windows Enhanced Metafile Plus
'PICT' Mac OS (does not have 512-byte file-based header)
'EPS ' Embedded PostScript
'PNGf' Bitmap image format
'FILE' Result of an Insert File command
'PNTG' MacPaint
'FPix' Flash (FPX)
'qtif' QuickTime image file
'FORK' Resource fork (Mac OS)
'.SGI' Generic bitmap format
'GIFf' Graphics Interchange Format
'snd ' Standard sound (Mac OS raw format)
'JPEG' Photographic images
'TIFF' Raster file format for digital images
'JP2 ' JPEG 2000
'TPIC' Targa
'META' Windows Metafile (enhanced)
'XMLO' Layout objects
'METO' Windows Metafile (original)
'8BPS' PhotoShop (PSD)
'moov' Old QuickTime format (Mac OS)
So with this information, my questions are:
- How do I retrieve contents with multiple formats?
- How do I render the BLOG into an image on the page?
Any suggestions would be much appreciated!
Thanks, but I think I found out what was going on. If I did an inner join between an image table and another table, the image wasn't being returned (or being returned properly...not sure which). As soon as I ran a query against the image table directly, images were returned.
So this did not work: select * from biography_table b inner join image_table i on b.stocknumber = i.stocknumber where b.stocknumber = 12345
But this does: select * from image_table where stocknumber = 12345
This means I have to run 2 separate queries, but at least I'm seeing data!!
If you cannot predict what the file type will be, AND/OR you need to use other extensions (such as docx, xlsx, etc), then you can exclusively use 'FILE' for all of your storage and retrieval scripts.
However doing it this way means that FileMaker does not know natively how to handle and open the file. In other words, when using FileMaker you will need to manually export the contents of the field to edit/view it, instead of being able to simply double click the field and it opens the file. So either the setup is advantageous to FileMaker, or advantageous to your external application.
If you do it this way, all files in container fields will be called 'Untitled.dat' and their internal name will be '?', so you will also need to store in another field the actual file name or its extension so you can open it later.
It is because you are using JPG instead of JPEG, in fact, your question answers itself. You can read it this way
SELECT GetAs(Image, 'JPEG') ...
And then, if you are using ado.net read it this way
var bytesLength = reader.GetBytes(0, 0, null, 0, 0);
var buffer = new Byte[bytesLength];
var bytes = reader.GetBytes(0, 0, buffer, 0, (int)bytesLength);
using (var fileStream = new FileStream(String.Format("{0}.jpg", Guid.NewGuid().ToString()), FileMode.Create, FileAccess.Write)) {
fileStream.Write(buffer, 0, buffer.Length);
}
Where 0 at the beggining of the the GetBytes function is the index of the photo field.
Buy a license of SuperContainer (shameless plug alert: I'm one of the authors) and a Mac Mini to host it on. Move the files out of your container fields and into SuperContainer, and let SuperContainer render image versions of your files by tapping into OS X's CoreImage libs.
精彩评论