Hello everyone
I have the following:
Web2py on Freebsd.
Database: SQLServer 2008
Connection: web2py <-> pyodbc <-> UnixODBC <-> FreeTDS <-> SQLServer
I'm trying to store some uploaded files into a blob field, instead than on the file system.
The table was created by the administrator SQLServer
CREATE TABLE [dbo].[DocumentosBlob](
[Id] [numeric](18, 0) IDENTITY(1,1) NOT NULL,
[Nombre] [varchar](50) NULL,
[Archivo] [varchar](512) NULL,
[Archivo_Blob] [text] NULL,
[Archivo_Blob2] [image] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
The adapter defines SQLServer blob fields as IMAGE ('blob': 'IMAGE',). Then use for testing the Archivo_Blob2 field is set to IMAGE
In my model I have:
tb_documentos_blob = db.define_table('DocumentosBlob',
Field('nombre', length=50),
Field('archivo', 'upload', uploadfield='archivo_blob2'),
Field('archivo_blob2', 'blob', writable=False, readable=False),
migrate=False,
)
But it happens that when trying to upload a file upload the following error occurs:
DataError: ('22018', '[22018] [FreeTDS][SQL Server]Operand type clash: text is incompatible with image (206) (SQLExecDirectW)')Then I changed the field, using one type TEXT (Archivo_Blob). The model will now be:
tb_documentos_blob = db.define_table('DocumentosBlob',
Field('nombre', length=50),
Field('archivo', 'upload', uploadfield='archivo_blob'),
Field('archivo_blob', 'blob', writable=False, readable=False),
migrate=False,
)
Now it works, I can upload and download files, but only with very small files. Tested with 20KB. With one of 250KB upload it, but at download it is broken. I imagine that was truncated when stored in the database.
How I can fix this?
Best Regards
José