1

I have public API's and I would like to set a quota policy based on the type of consumption.

  1. The user can hit the API with an image or a PDF(multi-page). If it is a PDF, based on the number of pages the quota counter should get updated.

  2. I want to access the PDF object in a Python callout so that I could extract the page count.

  3. Based on the number of pages, I would like to reject a request.

Python Callout Code

import re

request_pdf_file = open(PDF_FILE, 'rb', 1 )
for vLine in request_pdf_file.readlines():
    if b"/Count " in vLine:
        vPages = int(re.search(b"/Count \d*", vLine).group()[7:] )

return vPages

So my query is : How to access a PDF object from the request in a variable in Apigee

Thanks

Kartik Domadiya
  • 29,868
  • 19
  • 93
  • 104
moonwalker7
  • 1,122
  • 3
  • 11
  • 29

0 Answers0