Esempio n. 1
0
def upload(request):
	if request.method == 'POST':
		file_contents = request.FILES
		form = UploadFileForm(request.POST, request.FILES)
		print 'form: ' + str(form)
		if form.is_valid():
			pdf_name = str(file_contents['file'])
			handle_uploaded_file(request.FILES['file'], pdf_name)
		
			text_array = runner.pdf_to_text(pdf_name)	
			text = ''.join(text_array)
			context = { 'text': text }

		# png_filepaths = runner.pdf_to_pnglist(pdf_name)
		# return StreamingHttpResponse(request, png_filepaths)
		# return stream_response(request)
		
	
			#if file_contents:
			return render(request, 'pdfocr/results.html', context)
			#else:
		 		# TODO: Graceful failure
		 		#return HttpResponse('Failed to upload file. Try again.')
		else:
			return HttpResponse('Failed to upload file. Try again.')
Esempio n. 2
0
def upload_file(request):
    if request.method == 'POST':
        form = UploadFileForm(request.POST, request.FILES)
        if form.is_valid():
            form.save()
            #save_file(f)
            return HttpResponseRedirect('/')
    
    form = UploadFileForm()
    return direct_to_template(request, 'upload.html', 
            {'form': form})
Esempio n. 3
0
def upload_file(request):

    if request.method == "POST":
        form = UploadFileForm(request.POST, request.FILES)
        if form.is_valid():
            # return a response from this page
            # name_list = handle_uploaded_file(request.FILES['file'])
            if handle_uploaded_file(request.FILES["file"]):
                return HttpResponseRedirect("/upload/success/")
                # return render_to_response('uploader/results.html',
                # name_list,
                # context_instance=RequestContext(request))

    else:
        form = UploadFileForm()
    return render_to_response("uploader/index.html", {"form": form}, context_instance=RequestContext(request))
Esempio n. 4
0
def upload_handler(request):
    view_url = reverse('up5.upload_test.views.upload_handler')
    if request.method == 'POST':
        form = UploadFileForm(request.POST, request.FILES)
        if form.is_valid():
            form.save()
        return HttpResponseRedirect(view_url)

    upload_url, upload_data = prepare_upload(request, view_url)
    form = UploadFileForm()
    print(request.user.social_auth.get().extra_data)
    return direct_to_template(request, 'upload2.html',
            {'form':form, 'upload_url': upload_url,
                'upload_data': upload_data,
                'uploads': reversed(UploadFileModel.objects.all()),
                'user': request.user.social_auth.all()})
Esempio n. 5
0
def index(request):
    status = 'none'
    indexContext = {'status': message['none']}

    if request.method == 'POST':
        form = UploadFileForm(request.POST, request.FILES)
        if form.is_valid():
            mSound3dGenerator = sound3dGenerator(request.FILES['musicFile'])
            response = mSound3dGenerator.gen_online()
            if response:
                indexContext['status'] = message['none']
                return response
            else:
                indexContext['status'] = message['failGenerate']
        else:
            indexContext['status'] = message['failUpload']

    form = UploadFileForm()
    indexContext['form'] = form
    return render(request, 'sound3d/index.html', indexContext)
Esempio n. 6
0
def upload_file(request):
    if request.method == 'POST':
        form = UploadFileForm(request.POST, request.FILES)
        if form.is_valid():
            form.save()
            #save_file(f)
            return HttpResponseRedirect('/')

    form = UploadFileForm()
    return direct_to_template(request, 'upload.html', {'form': form})
Esempio n. 7
0
def upload_handler(request):
    view_url = reverse('up5.upload_test.views.upload_handler')
    if request.method == 'POST':
        form = UploadFileForm(request.POST, request.FILES)
        if form.is_valid():
            form.save()
        return HttpResponseRedirect(view_url)

    upload_url, upload_data = prepare_upload(request, view_url)
    form = UploadFileForm()
    print(request.user.social_auth.get().extra_data)
    return direct_to_template(
        request, 'upload2.html', {
            'form': form,
            'upload_url': upload_url,
            'upload_data': upload_data,
            'uploads': reversed(UploadFileModel.objects.all()),
            'user': request.user.social_auth.all()
        })