Subversion Repositories SmartDukaan

Rev

Rev 16824 | Rev 16826 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 16824 Rev 16825
Line 167... Line 167...
167
            
167
            
168
    def on_post(self, request, resp):
168
    def on_post(self, request, resp):
169
        
169
        
170
        try:
170
        try:
171
            boundary = request.content_type.split(";")[1].strip().split("=")[1]
171
            boundary = request.content_type.split(";")[1].strip().split("=")[1]
-
 
172
            pdict= {'boundary':boundary}
172
            chunks = []
173
            chunks = []
173
            filepath = "/tmp/rejectfile"
174
            filepath = "/tmp/rejectfile"
174
            with open(filepath, 'wb') as image_file:
175
            with open(filepath, 'wb') as image_file:
175
                while True:
176
                while True:
176
                    chunk = request.stream.read(4096)
177
                    chunk = request.stream.read(4096)
177
                    if not chunk:
178
                    image_file.write(chunk)
178
                        break
-
 
179
                    chunks.append(chunk) 
-
 
180
                
-
 
181
                chunk = "".join(chunks)
-
 
182
                nextpart = "--" + boundary
-
 
183
                lastpart = "--" + boundary + "--"
-
 
184
                
-
 
185
                print chunk
-
 
186
                chunk = find_between(chunk, nextpart, lastpart)
179
                print cgi.parse_multipart(image_file, pdict)
187
                chunk = chunk.split("\n\n")[1]
-
 
188
                print chunk
-
 
189
                image_file.write(chunk)
-
 
190
            rejectCount = process_rejects(filepath) #this function is not yet implemented
180
            rejectCount = process_rejects(filepath) #this function is not yet implemented
191
            rejectCount = 1
181
            rejectCount = 1
192
            resp.content_type = 'text/html'
182
            resp.content_type = 'text/html'
193
            resp.body = """
183
            resp.body = """
194
                <html><head><title>Upload Rejects</title></head><body>
184
                <html><head><title>Upload Rejects</title></head><body>