def execute(self): logging.info("dict: %s" % self.__dict__) response = {} if self.files: added = [] for upload in self.files.getlist("upload[]"): logging.info("upload %s" % upload) m = Picture() m.upload_content(upload) m.put() Picture.get(m.key()) added.append(m) response["added"] = self.get_files_and_dirs(added) else: response = Command.get_error( "Faild to upload picture, maximum upload data must not exceed 2.5MB" ) # settings.py:FILE_UPLOAD_MAX_MEMORY_SIZE import pprint logging.info("Uploae resposne: \n%s" % pprint.pformat(response)) return response
def image_upload(request): if request.method == 'POST': formset = UploadFileForm(request.POST, request.FILES) if formset.is_valid(): movie = Picture() movie.upload_content(request.FILES['file']) movie.put() Picture.get(movie.key()) return redirect(image_list) else: formset = UploadFileForm() return render_to_response("image_upload.html", { "formset" : formset }, context_instance=RequestContext(request))
def image_add(request): formset = None urlfetch = request.POST.get('urlfetch') if urlfetch: movie = Picture() movie.fetch_content(urlfetch) movie.put() Picture.get(movie.key()) return redirect(image_list) else: formset = AddImmageForm() return render_to_response("image_add.html", { "formset" : formset }, context_instance=RequestContext(request))