Exemplo n.º 1
0
def api_file_id(id):
    """Database table row endpoint. Retrieve (GET) or update (PUT) record."""
    log_request(request)
    try:
        if request.method == 'PUT':
            return api.response(api.File().update(id, request, sso.uid))
        elif request.method == 'GET':
            return api.response(api.File().fetch(id))
        else:
            raise api.MethodNotAllowed(
                f"Method {request.method} not supported for this endpoint.")
    except Exception as e:
        return api.exception_response(e)
Exemplo n.º 2
0
def api_file_owned():
    """Return JSON listing of files owned by currently authenticated person. Slightly 'special' endpoint that accepts only GET method and no parameters of any kind. Data is returned based on the SSO session role. Specially created for Upload and Manage UI, to list user's files."""
    log_request(request)
    try:
        return api.response(api.File().search(owner=sso.uid or ''))
    except Exception as e:
        return api.exception_response(e)
Exemplo n.º 3
0
def api_file_schema():
    """Create data schema JSON for client FORM creation."""
    log_request(request)
    try:
        return api.response(api.File().schema())
    except Exception as e:
        return api.exception_response(e)
Exemplo n.º 4
0
def download(path=None):
    if not path:
        return "Not Found", 404
    try:
        return api.File().download(path, sso.role)
    except Exception as e:
        app.logger.exception(str(e))
        return "Internal Server Error", 500
Exemplo n.º 5
0
def sample_save_from_filesystem(filename):
    user = api.current_user()
    if user:
        try:
            fileHandle = api.File(filename)
            oid = api.save_file(user, fileHandle)
            return api.url_for(user, oid)
        except IOError:
            pass
    return ''
Exemplo n.º 6
0
 def file_api(self):
     # circular dependency import
     import api
     api_instance = api.File(self)
     return api_instance