So, I have code that allows me to upload an image (thanks all). I read
in my file and drop it into a BlobCol of my object then store it in the
database. The problem is that the field in table is a TINYBLOB and I
need a LONGBLOB. I went looking on the sqlobject web site and I
couldn't find the docs for the way to setup a BlobCol to be something
larger than a TINYBLOB.
Anyone know how? Thanks...
----- Form
<form method="POST" action="saveprod" enctype="multipart/form-data">
<input type="hidden" name="dbid" py:attrs="value=dbid"/>
<p><input type="file" name="image" size="50"/></p>
<input type="submit" value="Submit" name="B1" />
<input type="reset" value="Reset" name="B2" />
</form>
----- Processing Routine
def saveprod(self, image, **kw):
object = None
dbid = int(kw['dbid'])
# Access / Create Record
model.hub.begin()
if dbid: object = model.Products.get(dbid)
else: object = model.Products()
total_data =''
while True:
data = image.file.read(8192)
if not data:
break
total_data += data
object.image = total_data
model.hub.commit()
model.hub.end()
raise cherrypy.HTTPRedirect(turbogears.url('/prodlist'))
---- Object
class Products(SQLObject):
image = BLOBCol(default=None)