def test_upload(): api.login("system", os.getenv("SYSTEM_PWD")) headers = api.headers() params = {'key': api.API_KEY} file_url = api.url('/api/file/schema.txt') files = {'file': open(api.schema_path(), 'rb')} resp = requests.post(file_url, params=params, headers=headers, files=files) resp.raise_for_status() node = resp.json() file_id = node['uid'] files = {'file': open(api.schema_path(), 'rb')} resp = requests.put(file_url, params=params, headers=headers, files=files) resp.raise_for_status() # download by path resp = requests.get(file_url, params=params, headers=headers) resp.raise_for_status() print(resp.text) # download by id file_url2 = api.url('/api/file/{0}'.format(file_id)) resp = requests.get(file_url2, params=params, headers=headers) resp.raise_for_status() print(resp.text) resp = requests.delete(file_url, params=params, headers=headers) resp.raise_for_status()
def test_delete_file_node(): api.login("system", os.getenv("SYSTEM_PWD")) headers = api.headers() params = {'key': api.API_KEY} file_url = api.url('/api/file/schema2.txt') files = {'file': open(api.schema_path(), 'rb')} resp = requests.post(file_url, params=params, headers=headers, files=files) resp.raise_for_status() node = resp.json() file_id = node['uid'] # download by path resp = requests.get(file_url, params=params, headers=headers) resp.raise_for_status() print(resp.text) # download by id url1 = api.url(f'/api/file/{file_id}') resp = requests.get(url1, params=params, headers=headers) resp.raise_for_status() print(resp.text) url2 = api.url(f'/api/data/file/{file_id}') resp = requests.delete(url2, params=params, headers=headers) resp.raise_for_status()
def test_delete_file_node(): api.login("system", os.getenv("SYSTEM_PWD")) headers = api.headers() params = {'key': api.API_KEY} file_url = api.url('/api/file/schema2.txt') files = {'file': open(api.schema_path(), 'rb')} resp = requests.post(file_url, params=params, headers=headers, files=files) resp.raise_for_status() node = resp.json() file_id = node['uid']
def test_delete_file_by_id(): api.login("system", os.getenv("SYSTEM_PWD")) headers = api.headers() params = {'key': api.API_KEY} file_url = api.url('/api/file/schema3.txt') files = {'file': open(api.schema_path(), 'rb')} resp = requests.post(file_url, params=params, headers=headers, files=files) resp.raise_for_status() node = resp.json() file_id = node['uid'] url2 = api.url(f'/api/file/{file_id}') resp = requests.delete(url2, params=params, headers=headers) resp.raise_for_status() resp = requests.get(file_url, params=params, headers=headers) assert (resp.status_code == 404) file_url2 = api.url(f'/api/file/{file_id}') resp = requests.get(file_url2, params=params, headers=headers) assert (resp.status_code == 404)
#!/usr/bin/env python import os import utils import api from minio import Minio import boto3 from botocore.client import Config utils.enable_logging_with_headers() filename = api.schema_path() access_key = os.getenv('AWS_ACCESS_KEY_ID') secret_key = os.getenv('AWS_SECRET_ACCESS_KEY') bucket_name = os.getenv('AWS_S3_BUCKET') # mc = Minio( # # 'localhost:4200/api/s3', # 'localhost:9000', # access_key=access_key, # secret_key=secret_key, # secure=False, # ) # mc.fput_object(bucket_name, 'schema.txt', filename) s3 = boto3.resource( 's3', endpoint_url='http://localhost:9000', aws_access_key_id=access_key,