Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

How to get binary post data in Django !nicely? -


forgive me if bit of newbie question, started learn django yesterday, , i'm trying not bad habits, i.e. trying things "the django way" start.

i have view recieves binary data http post field. django of course autoconverts binary data unicode string.

my question is, how raw binary data?

a couple of things occurred me. let request request i'm processing.

  • using request.raw_post_data involve parsing data again - when appearantly request.post stores raw data , trying around on-the-fly conversion (and besides, new in development version).
  • using base64 or transfer data work, seems overhead when data transfer not problem.
  • doing request.encoding="foo" before getting field (and reassigning afterwards) doesn't work either because still unicode string, besides feeling bit of dirty hack. using "base64" here (not bad transfer encoding) gives me assertionerror.

thanks in advance ideas!

edit: clarify - not talking classic file upload here, binary data stored in post field. i'd way because way want interface view via upload script. using normal post field makes both client , server simpler in case.

some might storing binary data in standard form field bad habit in way :)

you use standard library methods of python convert string binary representation.

take @ binascii — convert between binary , asci


posting before edit:

what piece of code (receiving data post)

def handlefile(self, request):     file = request.files["file"]     destination = open('filename.ext', 'wb')         chunk in file.chunks():             destination.write(chunk)     destination.close() 

works me.


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -