How can I create "upload" files with web2py -


i have app running on web2py. app want store lot of files database each user, can either upload own computer or can create online , save. these files can either text or binary files, if created in app, text. have 2 ways files come in have handle:

1) uploads through form. database has "file" field of type "upload" store using:

db.allfiles.insert(filename=filename, \      file=db.allfiles.file.store(file.file,filename),user=me)  

this creates file unique string attached name in uploads directory. solution pretty easy.


2) i need store files come in strings via json call. not sure how create "upload" type files , give them unique names in uploads directory. can give insight?

thanks

i think can incoming data, turn in-memory stream , store @ 1)

import stringio filehandle = stringio.stringio ( jsonvar ) 

Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -