Beispiel #1
0
 def get(filename: str) -> Response:  # pragma: no cover
     entity = Entity.get_by_id(int(Pathlib_path(filename).stem), types=True)
     license_ = get_license(entity)
     if not license_:
         raise AccessDeniedError
     parser = image.parse_args()
     if parser['download']:
         return send_file(
             f"{app.config['UPLOAD_DIR']}/{filename}",
             as_attachment=True)
     if parser['image_size'] and check_processed_image(filename):
         size = app.config['IMAGE_SIZE'][parser['image_size']]
         return send_from_directory(
             f"{app.config['RESIZED_IMAGES']}/{size}",
             filename)
     return send_from_directory(app.config['UPLOAD_DIR'], filename)
Beispiel #2
0
def get_file(
        links_inverse: list[Link],
        parser: dict[str, Any]) -> list[dict[str, Any]]:
    files = []
    for link in links_inverse:
        if link.domain.class_.name != 'file':
            continue
        path = get_file_path(link.domain.id)
        files.append({
            'id': link.domain.id,
            'name': link.domain.name,
            'fileName': path.name if path else None,
            'license': get_license(link.domain),
            'source':
                link.domain.description if link.domain.description else None})
    if parser['format'] == 'xml':
        return [{'file': file} for file in files]
    return files
Beispiel #3
0
def get_lp_file(links_inverse: list[Link]) -> list[dict[str, str]]:
    files = []
    for link in links_inverse:
        if link.domain.class_.name != 'file':
            continue
        path = get_file_path(link.domain.id)
        files.append({
            '@id':
            url_for('api_03.entity', id_=link.domain.id, _external=True),
            'title':
            link.domain.name,
            'license':
            get_license(link.domain),
            'url':
            url_for('api.display', filename=path.name, _external=True)
            if path else "N/A"
        })
    return files