Ejemplo n.º 1
0
def export_iavm_to_cpe_doc(request):
    """                                                                         
    Create a ZIP file on disk and transmit it in chunks of 8KB,                 
    without loading the whole file into memory. A similar approach can          
    be used for large dynamic PDF files.                                        
    """
    tempx = tempfile.NamedTemporaryFile(delete=False)
    IAVM.export_iavm_to_cpe_doc(tempx)
    tempz = tempfile.NamedTemporaryFile(delete=False)
    #tempz.close()
    archive = zipfile.ZipFile(tempz, 'w', zipfile.ZIP_DEFLATED)
    archive.write(tempx.name,"u_iavm-to-cpe.xml")
    archive.close()
    tempz.seek(0)
    chunk_size = 8192
    #response = StreamingHttpResponse(FileWrapper(open(tempz.name), chunk_size), content_type="application/zip")
    #response['Content-Disposition'] = 'attachment; filename=u_iavm-to-cpe.zip' 
    #response['Content-Length'] = os.path.getsize(tempz.name)
    #wrapper = FileWrapper(file(tempz), "rb")
    #response = HttpResponse(wrapper, content_type='application/zip')
    #response['Content-Disposition'] = 'attachment; filename=test.zip'
    #response['Content-Length'] = tempz.tell()
    response = HttpResponse(tempz.read())
    response['Content-Disposition'] = 'attachment; filename=u_iavm-to-cpe.zip' 
    response['Content-Type'] = 'application/x-zip'
    return response

    return response
Ejemplo n.º 2
0
def export_iavm_to_cpe_doc(request):
    """                                                                         
    Create a ZIP file on disk and transmit it in chunks of 8KB,                 
    without loading the whole file into memory. A similar approach can          
    be used for large dynamic PDF files.                                        
    """
    tempx = tempfile.NamedTemporaryFile(delete=False)
    IAVM.export_iavm_to_cpe_doc(tempx)
    tempz = tempfile.NamedTemporaryFile(delete=False)
    # tempz.close()
    archive = zipfile.ZipFile(tempz, "w", zipfile.ZIP_DEFLATED)
    archive.write(tempx.name, "u_iavm-to-cpe.xml")
    archive.close()
    tempz.seek(0)
    chunk_size = 8192
    # response = StreamingHttpResponse(FileWrapper(open(tempz.name), chunk_size), content_type="application/zip")
    # response['Content-Disposition'] = 'attachment; filename=u_iavm-to-cpe.zip'
    # response['Content-Length'] = os.path.getsize(tempz.name)
    # wrapper = FileWrapper(file(tempz), "rb")
    # response = HttpResponse(wrapper, content_type='application/zip')
    # response['Content-Disposition'] = 'attachment; filename=test.zip'
    # response['Content-Length'] = tempz.tell()
    response = HttpResponse(tempz.read())
    response["Content-Disposition"] = "attachment; filename=u_iavm-to-cpe.zip"
    response["Content-Type"] = "application/x-zip"
    return response

    return response
Ejemplo n.º 3
0
def generate_iavm_to_cpe_doc(request):
    if request.method == 'POST':
        try:
            IAVM.iavm_to_cpe_doc()
            return render(request,'iavm_apply.html',{'disa_pki_flag':disa_pki_flag})
        except:
            return render(request,'iavm_apply.html',{'disa_pki_flag':disa_pki_flag})
    else:
            return render(request,'iavm_apply.html',{'disa_pki_flag':disa_pki_flag})
Ejemplo n.º 4
0
def generate_iavm_to_cpe_doc(request):
    if request.method == "POST":
        try:
            IAVM.iavm_to_cpe_doc()
            return render(request, "iavm_apply.html", {"disa_pki_flag": disa_pki_flag})
        except:
            return render(request, "iavm_apply.html", {"disa_pki_flag": disa_pki_flag})
    else:
        return render(request, "iavm_apply.html", {"disa_pki_flag": disa_pki_flag})