コード例 #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)
コード例 #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)
コード例 #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)
コード例 #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
コード例 #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 ''
コード例 #6
0
ファイル: vm.py プロジェクト: mikelangelo-project/osv_proxy
 def file_api(self):
     # circular dependency import
     import api
     api_instance = api.File(self)
     return api_instance