No really, I need only that the app admin can change the logo in the
webapp, and for this
only is needed upload the file to applications/myapp/static/**images

Christian


2012/11/13 Derek <sp1d...@gmail.com>

> Wouldn't that also leave the uploaded file in the uploads folder?
>
> On Tuesday, November 13, 2012 10:00:24 AM UTC-7, Christian Espinoza wrote:
>>
>> Well, thanks anyway, its was resolved using the base code from
>> http://stackoverflow.com/**questions/8008213/web2py-**
>> upload-with-original-filename<http://stackoverflow.com/questions/8008213/web2py-upload-with-original-filename>
>>
>> Using for model:
>>
>>  Field("file", "upload", custom_store=store_file, custom_retrieve=
>> retrieve_file)
>>
>> and implementing these functions on this way:
>>
>> import os
>> import shutil
>>
>> def store_file(file, filename=None, path=None):
>>     path = "applications/myapp/static/**images"
>>     if not os.path.exists(path):
>>          os.makedirs(path)
>>     pathfilename = os.path.join(path, filename)
>>     dest_file = open(pathfilename, 'wb')
>>     try:
>>             shutil.copyfileobj(file, dest_file)
>>     finally:
>>             dest_file.close()
>>     return filename
>>
>> def retrieve_file(filename, path=None):
>>     path = "applications/myapp/static/**images"
>>     return (filename, open(os.path.join(path, filename), 'rb'))
>>
>> With this code was enough to get the uploaded files with the original
>> name and to change the logo online.
>>
>> Thanks to Wikus van de 
>> Merwe<http://stackoverflow.com/users/1054145/wikus-van-de-merwe>
>>
>> Christian.
>>
>> El lunes, 12 de noviembre de 2012 18:50:57 UTC-3, Christian Espinoza
>> escribió:
>>>
>>> Hello, maybe this question was some answers, ie
>>> http://groups.google.com/**group/web2py/browse_thread/**
>>> thread/b04977ace137b317/**f4c3e44b4cd5de6d?lnk=gst&q=**
>>> Change+upload+behaviour#**f4c3e44b4cd5de6d<http://groups.google.com/group/web2py/browse_thread/thread/b04977ace137b317/f4c3e44b4cd5de6d?lnk=gst&q=Change+upload+behaviour#f4c3e44b4cd5de6d>
>>>
>>> But I don't understand if  these args (custom_store  or custom_retrieve)
>>> could be necessary for that I need
>>>
>>> I have this statement on my model
>>>
>>> Field('logo', 'upload', uploadfolder='applications/**myapp/static/images',
>>> label='Logo (227x40px)')
>>>
>>> I need upload a file.png or logo.png called file and store it on
>>> 'applications/myapp/static/**images' with 'logo.png' as filename to
>>> replace
>>> the app logo on my app..
>>>
>>> there are a simple way to do that?
>>>
>>> Thanks in advance.
>>> Christian.
>>>
>>  --
>
>
>
>

-- 



Reply via email to