Solution: Exporting Blobs
Exporting Blobs from OpenBase
This example transport copies images (one per row) stored in the OpenBase
TalentPhoto table, into individual image files. Each image file name contains
the primary key.
For this example, the TalentPhoto table comes from the Movies
application and database example included with WebObjects.
In this example, the database server used is OpenBase, but Sybase and
Oracle and any database that supports binary large objects (blobs) will
work just as well.
This transport is interesting in that it doesn't just create a single
output file, but many files: one image file for each row in the table.
The basic transport is simple in that it transports the Talent primary
key to a text file. Nine lines of custom script extract the photos into
individual files, named by their primary key.
Photo Transport
The transport file used in this example is photo.transport,
and this is a report of its contents:
Transport.
photo.transport
Folder.
/Schema/work2000
Source.
EOF entity: TalentPhoto
Model path: /Schema/EOFTransports/OpenBase.eomodeld
Attributes:
photo photo TEXT 20
talentId talentId INT 2
Destination.
File: /Schema/EOFTransports/photos.data
End of record: \n
Columns:
talentId string 0
Expressions.
talentId = talentId
Row Preprocessing.
if photo != NULL {
declare N string = "/tmp/photo-" +
convert(string,talentId) + ".data"
print "CREATING FILE ", N
declare F TText
redirect F to file N
print to F photo
reset F
remove F, N
}
End.
|