Ah, that's what I love about web2py and python - things like this are not
too difficult to accomplish, especially since a lot of it is built into the
standard libraries.
,
On Thursday, March 22, 2012 11:19:16 AM UTC-7, LeMogwaï wrote:
>
> Thank you Anthony, you helped me for the first step.
>
> I found the SQLFORM.factory concept and together with your info, I've been
> able to get my file and start to process it.
>
> Now, here is how my action looks like:
>
> @auth.requires_login()
> def dbimport():
> result = "Please, upload a packed database"
> form = SQLFORM.factory(Field('packed_db', 'upload', label=T('Packed
> database to load'), uploadfolder='uploads'))
> if form.process().accepted:
> response.flash = 'Machin chargé'
> result = packed_db_process(request.vars.packed_db.file)
> elif form.errors:
> response.flash = 'Pwët error'
> return dict(form=form, result=result)
>
> Note that the file does not appear in the uploads folder! That's the
> reason why I first was disappointed. But the file is still in memory!
>
> Now that I'm able to process my file (with the zipfile module) I'm able to
> extract the csv and the pictures from it, but I need a function to encode
> the names from "product 0001.jpg" to
> "t_product.f_photo.xxxxxxxxxx.yyyyyyyy.jpg" and store them into the
> uploads directory.
>
> Ho, ho ! I think I just found a way there:
> http://web2py.com/books/default/chapter/29/6#Manual-uploads<http://web2py.com/books/default/chapter/29/6#Manual-uploads>
>
> I'll keep you in touch if I get stuck again.
>
> Thank you!
> Le Mogwaï
>
> Le jeudi 22 mars 2012 16:00:25 UTC+1, Anthony a écrit :
>>
>> Upon submission of the form, you should find the file itself in
>> request.vars.f_photo.file (and the filename in
>> request.vars.f_photo.filename).
>>
>> Anthony
>>
>