I found the solution:
http://groups.google.com/group/web2py/browse_thread/thread/451b3a8614aaf76c/bf16c51375dc1e72?lnk=gst&q=manual+upload#bf16c51375dc1e72

I am able to up/download files retrieved with the suds library..... if
i insert like:
db.srattachments.insert(filelink=db.srattachments.filelink.store(converted,filename),file=converted)


BTW: Massimo... web2py is great, the best, easiest & straightforward i
ever used for webapp development.

Stefan


On Sep 25, 5:09 pm, winti <[email protected]> wrote:
> I tried many different ways, but i ended with this. I checked also
> chapter 6.15 in the web2py manual and study the wiki example.
> If i upload a file manually and retrieve this i can download it
> without any issue.
> If i store the file in a blob field db.srattachments.file i am not
> able to retrieve the file.
>
> model:
> db.define_table("srattachments",
>         Field("Orderid","string",default="",readable=True,
> writable=False),
>         Field('file','blob',default=''),
>         Field('filelink','upload',uploadfield='file'),
>         Field('Comment','string',default=''),)
>
> controller:
>
> def getdoc():
>     ....
>     ....
>     getdok = mobileservice.service.ZMsGetDokuFiles(PARAMS......)
>     converted = base64.standard_b64decode(getdok)
>     db.srattachments.insert(file=converted,......)
>     .....
>
> def displaydoc():
>     ....
>     ....
>     orderdocs = db(db.srattachments.orderid==request.args[0]).select()
>     return dict(orderdocs=orderdocs)
>
> def download():
>     return response.download(request, db)
>
> view getdoc:
> {{for doc in orderdocs:}}
> {{=A(doc.id, _href=URL(r=request, f='download', args=doc.file))}}
> {{pass}}
>
> After clicking on the doc.id link i receive a very long 
> url:http://..../app/download/BinContentofDocumentStoredWithinSR.attachmen.............................
>
> For my understanding my issue may be releated to contend headers and
> the relation between the upload field and the blob field in the db
> which i still don't understand.
>
> Stefan
>
> On Sep 25, 6:42 am, mdipierro <[email protected]> wrote:
>
>
>
> > How are you retrieving it? Are you setting a content type and content
> > disposition in the header?
>
> > On Sep 24, 8:41 am, winti <[email protected]> wrote:
>
> > > Thank you massimo,
> > > this i tried allready and could store the data but not retrieve in a
> > > usefull format...
> > > How is it possible for downloading this stored file in field b
> > > providing the user a link within web2py ?
> > > I allways get rubish back or a huge url with the data stored within
> > > this field.
>
> > > Stefan
>
> > > On 24 Sep., 15:21, mdipierro <[email protected]> wrote:
>
> > > > if you have db.define_table('a',Field('b','blob'))
>
> > > > db.a.insert(b=converted)
>
> > > > On Sep 24, 4:34 am, winti <[email protected]> wrote:
>
> > > > > Hello,
> > > > > i am working on a project where web2py will be used as a online/
> > > > > offline frontent for mobile users ufor our ERP System.
> > > > > The communication from web2py to the backend system is implemented
> > > > > with the soap library suds.
> > > > > Now i am at the point to deal with exchanging files (pdf,
> > > > > pictures ....).
> > > > > Within python i am able to get files from the backend system:
> > > > > -----
> > > > > from suds.client import Client
> > > > > import base64
> > > > > urlmobileservice =  URL2WDSL
> > > > > mobileservice = Client(urlmobileservice)
> > > > > getdok = mobileservice.service.ZMsGetDokuFiles(SERVICEPARAMETERS)
> > > > > converted=base64.standard_b64decode(getdok.FileXsring)
> > > > > filename = "/tmp/test.pdf"
> > > > > file = open(filename, 'w')
> > > > > file.write(converted)
> > > > > file.close
> > > > > ----
> > > > > The file is saved correctly on the filesystem.
>
> > > > > Within web2py i would like to save the document (getdok) within the
> > > > > database as blob.
>
> > > > > Until now i did not find a proper way to store and retrieve this
> > > > > documents.
>
> > > > > Any examples ?
>
> > > > > Stefan- Zitierten Text ausblenden -
>
> > > > - Zitierten Text anzeigen -

Reply via email to