Explicitly calling the .store() method should work in 2.4.6, but this 
method:

db(db.mytable.id==24).update(file1=request.vars.file1)

doesn't work in any stable version -- it only works in trunk (and therefore 
will work in the next stable release).

Anthony

On Thursday, August 15, 2013 2:39:13 AM UTC-4, at wrote:
>
>
> Thank you Anthony!
>
> That means it should be working in 2.4.6-stable? we've 2.4.6-stable on 
> production server.
>
> Regards,
> AT
>
> On Thursday, 15 August 2013 10:55:50 UTC+5, Anthony wrote:
>>
>> Looks like there was a bug, which has now been fixed in trunk. So, the 
>> second version will work in the next stable release.
>>
>> Anthony
>>
>> On Thursday, August 15, 2013 1:26:18 AM UTC-4, at wrote:
>>>
>>>
>>> 2.4.5
>>>
>>> On Thursday, 15 August 2013 07:44:02 UTC+5, Anthony wrote:
>>>>
>>>> What version of web2py are you using?
>>>>
>>>> On Wednesday, August 14, 2013 9:22:57 PM UTC-4, at wrote:
>>>>>
>>>>> Thanks a lot anthony,
>>>>> db(db.mytable.id==24).update(file1=db.mytable.file1.store(request.vars
>>>>> .file1)) 
>>>>> works,
>>>>>
>>>>> whereas
>>>>> db(db.mytable.id==24).update(file1=request.vars.file1)
>>>>> gives error:
>>>>> <class 'gluon.contrib.pg8000.errors.ProgrammingError'> ('ERROR', 
>>>>> '22001', 'value too long for type character varying(512)')
>>>>>
>>>>> PS. I'd replied to your post yesterday, but somehow it was not posted 
>>>>>
>>>>> On Tuesday, 13 August 2013 19:19:44 UTC+5, Anthony wrote:
>>>>>>
>>>>>> On Tuesday, August 13, 2013 9:20:47 AM UTC-4, at wrote:
>>>>>>
>>>>>>>
>>>>>>> Here is my controller code:
>>>>>>> def test_upload:
>>>>>>>     if request.vars.file1 is not None:
>>>>>>>        result = db(db.mytable.id
>>>>>>> ==24).update(file1=request.vars.file1.file)
>>>>>>>
>>>>>>
>>>>>> request.vars.file1 is a cgi.FieldStorage object. The original 
>>>>>> filename is therefore in request.vars.file1.filename. 
>>>>>> request.vars.file1.file is a temporary file on the filesystem, and it 
>>>>>> does 
>>>>>> not contain the original filename (instead, it has a temporary filename 
>>>>>> with no extension). If you want to manually insert an uploaded file, you 
>>>>>> should pass the cgi.FieldStorage object to the .insert() or .update() 
>>>>>> method rather than passing only the .file object from it. So, should be:
>>>>>>
>>>>>> db(db.mytable.id==24).update(file1=request.vars.file1)
>>>>>>
>>>>>> which is equivalent to calling:
>>>>>>
>>>>>> db(db.mytable.id==24).update(file1=db.mytable.file1.store(request.
>>>>>> vars.file1)) 
>>>>>>
>>>>>> Anthony
>>>>>>
>>>>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to