Ok, I read the book, but I still don't really know how should this be done.
What I have is this table:
db.define_table('files',
Field('original_filename', 'string', required = True,notnull
= True),
Field('uploaded_file', 'upload', uploadfield =
'uploaded_data', required = True, notnull = True, requires = IS_NOT_EMPTY
()),
Field('uploaded_data', 'blob', notnull = True),
Field('created_on', 'datetime', notnull = True))
and this code:
db.files.insert(original_filename = upload.filename,
uploaded_file = db.files.uploaded_file.store(upload.file,upload
.filename),
created_on = datetime.today())
But this doesn't work because uploaded_data field is NULL. Shouldn't
store() take care of that field?
Or do I need to put file content there manually?
Thanks in advance.
2012. július 9., hétfő 16:54:26 UTC+2 időpontban Anthony a következőt írta:
>
> http://web2py.com/books/default/chapter/29/6#Manual-uploads
>
> On Monday, July 9, 2012 10:15:27 AM UTC-4, Athelionas wrote:
>>
>> What is the proper way of uploading a file without SQLFORM into the
>> following database table?
>>
>> db.define_table('files',
>> Field('original_filename', 'string'),
>> Field('file', 'upload', uploadfield='file_data'),
>> Field('file_data', 'blob'))
>>
>> A simple insert won't help here so I'm sure there's some kind of trick to
>> it which I'm unable to figure out on my own.
>>
>> Any help is highly appreciated!
>>
>