krutmaster

curl photoshop get file

Oct 10th, 2021 (edited)
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.52 KB | None | 0 0
  1. #!/bin/bash
  2. # set -x
  3.  
  4. # ************************************
  5. # Check if jq is installed
  6. # ************************************
  7. if [ ! `which jq` ]; then
  8.     echo "************************************"
  9.     echo "Please install jq: brew install jq"
  10.     echo "************************************"
  11.     exit 1
  12. fi
  13.  
  14. # ************************************
  15. # Set variables
  16. # ************************************
  17. token=''
  18. apiKey=''
  19. endpoint='https://image.adobe.io/pie/psdService/documentManifest'
  20. method='POST'
  21. payload='{
  22.  "inputs": [
  23.    {
  24.      "href": "https://github.com/AdobeDocs/cis-photoshop-api-docs/raw/main/sample_files/Sunflower.psd",
  25.      "storage": "external"
  26.    }
  27.  ],
  28.  "options": {
  29.    "thumbnails": {
  30.      "type": "image/png"
  31.    }
  32.  }
  33. }'
  34.  
  35. # ************************************
  36. # Call API
  37. # ************************************
  38. res=$(curl -k -Ss -H "Authorization: Bearer $token" -H "Content-Type:application/json" -H "x-api-key: $apiKey" -X "$method" -d "$payload" "$endpoint")
  39. myerror=$(echo $res | jq -r .code)
  40. if [ $myerror != "null" ]; then
  41.     echo "ERROR: $res"
  42.     exit 1
  43. fi
  44. jobid=$(echo $res | jq -r ._links.self.href)
  45. echo "JOBID: $jobid"
  46.  
  47. while [ "x$jobstatus" != "xsucceeded" ] && [ "x$jobstatus" != "xfailed" ]; do
  48.     output=$(curl -k -Ss -H "Authorization: Bearer $token" -H "Content-Type:application/json" -H "x-api-key: $apiKey" -X GET "$jobid" | jq -r '.outputs[0]')
  49.     jobstatus=$(echo $output | jq -r '.status')
  50.     echo "JOBSTATUS: $jobstatus"
  51. done
  52.  
  53. echo "RESULT"
  54. echo ""
  55. echo $output | jq
Add Comment
Please, Sign In to add comment