Upload File to GCP Storage using Apigee X Integration

Is it possible to upload a file to Google cloud storage using APIGEE X using integration. Can it be done using integration policy.

Can you explain in detail how to trigger API from APIGEE X  API to Integrations

1 1 347
1 REPLY 1

How to trigger an Integration from Apigee X? Apigee X includes an IntegrationCallout step (aka policy) that allows you to call out to API Integration.

If I were using Apigee to facilitate a simple file upload to Google Cloud Storage (GCS), I would:

  • Create a "loopback" API in Apigee X that validates credentials (oauth token or API key), and then generates a "signed URL" which allows time-limited access to GCS for upload. Call t his the "pre upload" API.
  • Have the client call that preupload API. In response it receives a unique signed URL that points to storage.googleapis.com
  • The client will then upload directly to GCS using that specific URL.
  • At that point if there is a need to process the file further, then:
    • configure your cloud storage bucket to issue a pubsub event on file upload (documentation)
    • configure App Integration with a pubsub trigger (documentation)

The last step there allows you to kick off any integration you would need on the uploaded file.

If there is a need to correlate the uploaded file with something else associated to the client, you can do that by using a specific folder within the GCS bucket, and allow the intiial Apigee API to place any additional data into that folder, as appropriate.  If you do this, there's a chance that Apigee  will issue a signed URL, but the client will fail to use it (won't upload, for some reason).  In which case, you would need a scheduled task to look for  "stale" upload metadata, and clean it out once per day, or week, or whatever. That can be done with Cloud Scheduler.