#!/usr/bin/env python3 """ Script to test Adobe PSD file upload """ import os import sys import json import time import requests from pathlib import Path # The same API credentials API_KEY = "f34becb759244899bd73b86220f6fb92" ACCESS_TOKEN = "eyJhbGciOiJSUzI1NiIsIng1dSI6Imltc19uYTEta2V5LWF0LTEuY2VyIiwia2lkIjoiaW1zX25hMS1rZXktYXQtMSIsIml0dCI6ImF0In0.eyJpZCI6IjE3NDQ4NzYzNDM5MzdfNTE1YjU0NTgtZDU3NC00N2RlLThmNzgtYjQ5MGMwYjZiOWYyX3VlMSIsIm9yZyI6IkZBRDYxRTI3NjY4NkRCM0QwQTQ5NUVDNEBBZG9iZU9yZyIsInR5cGUiOiJhY2Nlc3NfdG9rZW4iLCJjbGllbnRfaWQiOiJmMzRiZWNiNzU5MjQ0ODk5YmQ3M2I4NjIyMGY2ZmI5MiIsInVzZXJfaWQiOiJEQTM3MUY1NzY3RUJEMDdEMEE0OTVGOTRAdGVjaGFjY3QuYWRvYmUuY29tIiwiYXMiOiJpbXMtbmExIiwiYWFfaWQiOiJEQTM3MUY1NzY3RUJEMDdEMEE0OTVGOTRAdGVjaGFjY3QuYWRvYmUuY29tIiwiY3RwIjozLCJtb2kiOiIzMDA1NWZlNyIsImV4cGlyZXNfaW4iOiI4NjQwMDAwMCIsImNyZWF0ZWRfYXQiOiIxNzQ0ODc2MzQzOTM3Iiwic2NvcGUiOiJvcGVuaWQsQWRvYmVJRCxyZWFkX29yZ2FuaXphdGlvbnMifQ.P0J4J7Qy-zflhrq6u2JX1rXucimiwuR__bkXJnZ4ZSiNY9G6fMPL1ym0isrFTAadVisgJLlHsh0QQZpLY5l-Uv3XZZRWnbK7fo2uDy4j-o7Y4aO7vBQ-VyCS8C7D_msgnHHnFcxwYXGAmv10-AFUfBsw3Y1xRVjDMIJH1Ux8NdbZ8j1zJXN1FPuuBi8fH1hmKda85nuXJsKc7TqaYBzX4AGzWBPV6hyoKedzrNtPCNRx3muhHnCS_q6wmk6Jx6kVAxrYPeeoA-W-ZKJrP-5BhQf0KUVOBtaCBKlrDL-ftML0LZlWswB14kKTMkt9R7z6xwLyPWfD1ldFh3bEMaa0YA" def verify_auth(): """Verify authentication with Adobe API""" headers = {"Authorization": f"Bearer {ACCESS_TOKEN}"} response = requests.get( "https://ims-na1.adobelogin.com/ims/userinfo", headers=headers, timeout=20 ) print(f"Auth verification: {response.status_code}") if response.text: print(f"Auth response: {response.text}") return response.status_code == 200 def try_upload_with_alternative_api(psd_path): """Try to upload a PSD file using alternative Adobe APIs""" # Make sure the file exists and get its details if not os.path.exists(psd_path): print(f"Error: File not found: {psd_path}") return False file_size = os.path.getsize(psd_path) file_name = os.path.basename(psd_path) print(f"Testing upload for: {file_name} ({file_size} bytes)") # Standard headers for all requests headers = { "x-api-key": API_KEY, "Authorization": f"Bearer {ACCESS_TOKEN}", "Content-Type": "application/json" } # Try different upload approaches # 1. Try direct PS Upload API upload_endpoints = [ "https://photoshop.adobe.io/api/v1/uploads", "https://image.adobe.io/api/v2/uploads", "https://image.adobe.io/pie/psdService/upload", "https://api.adobe.io/assets", "https://cc-api.adobe.io/api/v1/assets", "https://cc-api-storage.adobe.io/api/v1/upload" ] print("\nTrying direct upload endpoints...") for endpoint in upload_endpoints: try: response = requests.get(endpoint, headers=headers, timeout=20) print(f" GET {endpoint}: Status {response.status_code}") # Try a small POST request too payload = {"filename": file_name, "contentType": "image/vnd.adobe.photoshop"} post_response = requests.post(endpoint, headers=headers, json=payload, timeout=20) print(f" POST {endpoint}: Status {post_response.status_code}") if post_response.status_code < 500 and post_response.text and len(post_response.text) < 500: print(f" Response: {post_response.text}") except Exception as e: print(f" Error with {endpoint}: {str(e)}") # 2. Check for alternatives to presignedUrl endpoint signed_url_endpoints = [ "https://image.adobe.io/pie/psdService/presignedUrl", "https://firefly-api.adobe.io/v2/storage/presignedUrl", "https://cc-api-storage.adobe.io/v2/presigned-url", "https://photoshop.adobe.io/api/v1/presignedUrl" ] print("\nTrying presigned URL endpoints...") for endpoint in signed_url_endpoints: try: # Prepare request for presigned URL presigned_url_payload = { "path": f"uploads/{file_name}", "contentType": "image/vnd.adobe.photoshop", "contentLength": file_size, "httpMethod": "PUT" } response = requests.post( endpoint, headers=headers, json=presigned_url_payload, timeout=20 ) print(f" POST {endpoint}: Status {response.status_code}") if response.text and len(response.text) < 500: print(f" Response: {response.text}") except Exception as e: print(f" Error with {endpoint}: {str(e)}") # 3. Try discovering endpoints through API documentation try: print("\nChecking Adobe API endpoints from documentation...") doc_response = requests.get( "https://developer.adobe.com/apis", headers=headers, timeout=20 ) print(f" Documentation response status: {doc_response.status_code}") except Exception as e: print(f" Error accessing documentation: {str(e)}") return False # Return False as we didn't successfully upload def main(): if len(sys.argv) < 2: print(f"Usage: {sys.argv[0]} ") sys.exit(1) psd_path = sys.argv[1] print("Adobe PSD Upload Test") print("-" * 40) # Verify authentication if not verify_auth(): print("Authentication failed! Cannot proceed with upload tests.") sys.exit(1) # Try the upload success = try_upload_with_alternative_api(psd_path) if success: print("Upload successful!") else: print("\nUpload testing complete but no successful method was found.") print("Check the output above for potential endpoints to investigate.") if __name__ == "__main__": main()