Пример #1
0
def analysis_handler(image_id, part_id, encoded_filepath):
    """Page that displays analysis results for a file."""
    file_path = urllib.unquote(encoded_filepath)
    image = Image.byId(image_id)
    image_part = Partition.byId(part_id)
    fs_ele = FileSysEle.fromImagePath(image.path, image_part, image.bps, file_path)

    # Do something for directory handling here, not sure what yet
    return render_template('analysis.html', image=image, partition=image_part, file_path=file_path)
Пример #2
0
def file_handler(image_id, part_id, encoded_filepath):
    """Display page for a file system element.
    If the element is a directory then the page displays the directory listing
    as read from the disk image.
    If a file is selected they files contents as a binary payload is sent in
    the Response.
    """
    file_path = urllib.unquote(encoded_filepath)
    image = Image.byId(image_id)
    image_part = Partition.byId(part_id)
    fs_ele = FileSysEle.fromImagePath(image.path, image_part, image.bps, file_path)
    if fs_ele.isDirectory():
        # Render the dir listing template
        files = FileSysEle.listFiles(image.path, image_part, image.bps, file_path)
        return render_template('directory.html', image=image,
                               partition=image_part, files=files)
    # Its a file so return the download
    temp_file, mime_type = FileSysEle.createTempCopy(image.path,
                                                     image_part.start,
                                                     image.bps, fs_ele)
    return send_file(temp_file, mimetype=mime_type, as_attachment=True, attachment_filename=fs_ele.name)