コード例 #1
0
def get_direct_file_url(service_id, document_id, key, sending_method):
    return url_for('download.download_document',
                   service_id=service_id,
                   document_id=document_id,
                   key=bytes_to_base64(key),
                   sending_method=sending_method,
                   _external=True)
コード例 #2
0
def get_frontend_download_url(service_id, document_id, key):
    scheme = current_app.config['HTTP_SCHEME']
    netloc = current_app.config['FRONTEND_HOSTNAME']
    path = 'd/{}/{}'.format(uuid_to_base64(service_id), uuid_to_base64(document_id))
    query = urlencode({'key': bytes_to_base64(key)})

    return urlunsplit([scheme, netloc, path, query, None])
コード例 #3
0
def get_direct_file_url(service_id, document_id, key, mimetype):
    return url_for(
        'download.download_document',
        service_id=service_id,
        document_id=document_id,
        key=bytes_to_base64(key),
        extension=current_app.config['ALLOWED_FILE_TYPES'][mimetype],
        _external=True
    )
コード例 #4
0
def get_frontend_download_url(service_id, document_id, key, filename):
    scheme = current_app.config['HTTP_SCHEME']
    netloc = current_app.config['FRONTEND_HOSTNAME']
    path = 'd/{}/{}'.format(uuid_to_base64(service_id),
                            uuid_to_base64(document_id))
    query_params = {'key': bytes_to_base64(key), 'filename': filename}
    query = urlencode({k: v
                       for k, v in query_params.items() if v},
                      quote_via=quote)

    return urlunsplit([scheme, netloc, path, query, None])
コード例 #5
0
def test_bytes_to_base64_to_bytes():
    b = os.urandom(32)
    b64 = bytes_to_base64(b)
    assert base64_to_bytes(b64) == b