86 lines
2.8 KiB
Python
86 lines
2.8 KiB
Python
import requests
|
|
import json
|
|
|
|
# Configuration
|
|
BASE_URL = "https://dev-api.oneskyit.com/v3/action/hosted_file"
|
|
API_KEY = "PMM4n50teUCaOMMTN8qOJA"
|
|
ACCOUNT_ID = "Q8lR8Ai8hx2FjbQ3C_EH1Q" # OSIT
|
|
|
|
# IDs for testing ID Vision resolution
|
|
HOSTED_FILE_ID = "PUwhbT2tMgU"
|
|
EVENT_FILE_ID = "cFyCd7FPZe9"
|
|
ARCHIVE_CONTENT_ID = "UjKzrk-GKu5"
|
|
|
|
# Hash for testing content-addressable storage
|
|
FILE_HASH = "384fef832fa07b347a1d70927d0606b24cf41771202c1bfa00d7026764db2bb2"
|
|
|
|
def test_download_by_id(label, test_id):
|
|
print(f"--- Testing Download via {label}: {test_id} ---")
|
|
url = f"{BASE_URL}/{test_id}/download"
|
|
headers = {"X-Aether-API-Key": API_KEY, "x-account-id": ACCOUNT_ID}
|
|
|
|
try:
|
|
response = requests.get(url, headers=headers, stream=True)
|
|
print(f"Status: {response.status_code}")
|
|
if response.status_code == 200:
|
|
print(f"✅ Success: Download via {label} works.")
|
|
return True
|
|
else:
|
|
print(f"❌ Failed: {response.text}")
|
|
return False
|
|
except Exception as e:
|
|
print(f"💥 Exception: {e}")
|
|
return False
|
|
|
|
def test_download_by_hash_query():
|
|
print(f"\n--- Testing Hash Download via Query Param API Key ---")
|
|
url = f"{BASE_URL}/hash/{FILE_HASH}/download?api_key={API_KEY}"
|
|
|
|
try:
|
|
response = requests.get(url)
|
|
print(f"Status: {response.status_code}")
|
|
if response.status_code == 200:
|
|
print("✅ Success: Hash download with query param works.")
|
|
return True
|
|
else:
|
|
print(f"❌ Failed: {response.text}")
|
|
return False
|
|
except Exception as e:
|
|
print(f"💥 Exception: {e}")
|
|
return False
|
|
|
|
def test_download_streaming():
|
|
print(f"\n--- Testing Byte-Range Streaming ---")
|
|
url = f"{BASE_URL}/{HOSTED_FILE_ID}/download"
|
|
headers = {
|
|
"X-Aether-API-Key": API_KEY,
|
|
"x-account-id": ACCOUNT_ID,
|
|
"Range": "bytes=0-10"
|
|
}
|
|
|
|
try:
|
|
response = requests.get(url, headers=headers)
|
|
print(f"Status: {response.status_code} (Expected 206)")
|
|
if response.status_code == 206:
|
|
print("✅ Success: Byte-range streaming works.")
|
|
return True
|
|
else:
|
|
print(f"❌ Failed: {response.status_code}")
|
|
return False
|
|
except Exception as e:
|
|
print(f"💥 Exception: {e}")
|
|
return False
|
|
|
|
if __name__ == "__main__":
|
|
results = [
|
|
test_download_by_id("Hosted File", HOSTED_FILE_ID),
|
|
test_download_by_id("Event File (ID Vision)", EVENT_FILE_ID),
|
|
test_download_by_id("Archive Content (ID Vision)", ARCHIVE_CONTENT_ID),
|
|
test_download_by_hash_query(),
|
|
test_download_streaming()
|
|
]
|
|
|
|
if all(results):
|
|
print("\n🎉 ALL DOWNLOAD PATTERNS VERIFIED!")
|
|
else:
|
|
print("\n❌ SOME TESTS FAILED.") |