import requests import os # Configuration BASE_URL = "https://dev-api.oneskyit.com/v3/action/event_file" API_KEY = "IDF68Em5X4HTZlswRNgepQ" ACCOUNT_ID = "Q8lR8Ai8hx2FjbQ3C_EH1Q" # OSIT def test_event_file_upload(): print("--- Testing Event File Upload via V3 Action ---") url = f"{BASE_URL}/upload" headers = { "X-Aether-API-Key": API_KEY, "x-account-id": ACCOUNT_ID } # Create a small dummy file test_filename = "v3_event_test.txt" with open(test_filename, "w") as f: f.write("This is a test file for V3 Event File Action.") data = { "account_id": ACCOUNT_ID, "for_type": "event", "for_id": "pjrcghqwert", # IDAA Recovery Meetings "event_id": "pjrcghqwert", "title": "V3 Test Upload", "description": "Uploaded via atomic V3 action" } files = [ ("file_list", (test_filename, open(test_filename, "rb"), "text/plain")) ] try: response = requests.post(url, headers=headers, data=data, files=files) print(f"Status: {response.status_code}") if response.status_code == 200: res_json = response.json() data_li = res_json.get("data", []) if data_li: ef = data_li[0] print(f"✅ Success: Event File Created!") print(f" Event File ID: {ef.get('id')}") print(f" Hosted File ID: {ef.get('hosted_file_id_random')}") print(f" Filename: {ef.get('filename')}") # Cleanup: try downloading it download_url = f"{BASE_URL}/{ef.get('id')}/download" print(f"\n--- Testing Download via Event File ID: {ef.get('id')} ---") dl_resp = requests.get(download_url, headers=headers) if dl_resp.status_code == 200: print("✅ Success: Download worked!") else: print(f"❌ Download Failed: {dl_resp.status_code}") return True else: print(f"❌ Failed: No data in response.") return False else: print(f"❌ Failed: {response.text}") return False except Exception as e: print(f"💥 Exception: {e}") return False finally: if os.path.exists(test_filename): os.remove(test_filename) if __name__ == "__main__": test_event_file_upload()